From bd7c126e3fb1b94e76e0e632c657cea854586844 Mon Sep 17 00:00:00 2001 From: Gábor Németh Date: Mon, 6 Mar 2023 16:19:14 +0100 Subject: Add 'dist-clean' command to remove packages and list files We assume all files in the 'listsdir' are candidates. Keep only files ending with Release, Release.gpg, and InRelease. Closes: #959093 --- apt-pkg/acquire.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'apt-pkg/acquire.h') diff --git a/apt-pkg/acquire.h b/apt-pkg/acquire.h index 17b68768e..46115a27f 100644 --- a/apt-pkg/acquire.h +++ b/apt-pkg/acquire.h @@ -70,6 +70,7 @@ #include #include +#include #include #include @@ -330,6 +331,14 @@ class APT_PUBLIC pkgAcquire * \return \b true if the directory exists and is readable. */ bool Clean(std::string Dir); + + /** Deletes each package list and index file in the given directory. + * + * \param Dir The directory to be cleaned. + * + * \return \b true if the directory exists and is readable. + */ + bool CleanLists(std::string Dir); /** \return the total size in bytes of all the items included in * this download. @@ -372,6 +381,20 @@ class APT_PUBLIC pkgAcquire private: APT_HIDDEN void Initialize(); + + /** Delete each entry in the given directory whose name does \em not match + * a criterion. + * + * \param Dir The directory to be cleaned. + * + * \param KeepP A predicate telling to keep the named file; if it is + * non-empty and returns true, the file is kept. + * + * \param Caller Log name of the caller. + * + * \return \b true if the directory exists and is readable. + */ + APT_HIDDEN static bool CleanDir(std::string Dir, std::function const &KeepP, char const * const Caller); }; /** \brief Represents a single download source from which an item -- cgit v1.2.3-70-g09d2