X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/3174e150a3c97a471998cfe73a11bd4996da9ab7..6ee2b0f83ea3c41b52c8076eac63f921c51b9887:/apt-pkg/acquire.h diff --git a/apt-pkg/acquire.h b/apt-pkg/acquire.h index 64dafdc9d..9e91a9f67 100644 --- a/apt-pkg/acquire.h +++ b/apt-pkg/acquire.h @@ -30,7 +30,7 @@ ##################################################################### */ /*}}}*/ -/** \defgroup acquire Acquire system +/** \defgroup acquire Acquire system {{{ * * \brief The Acquire system is responsible for retrieving files from * local or remote URIs and postprocessing them (for instance, @@ -54,7 +54,7 @@ * once, but it is not clear what its behavior in this case is, and * no subclass of pkgAcquire::Item seems to actually use this * capability. - */ + */ /*}}}*/ /** \addtogroup acquire * @@ -66,22 +66,21 @@ #ifndef PKGLIB_ACQUIRE_H #define PKGLIB_ACQUIRE_H +#include + #include #include using std::vector; using std::string; -#ifdef __GNUG__ -#pragma interface "apt-pkg/acquire.h" -#endif #include #include class pkgAcquireStatus; -/** \brief The core download scheduler. +/** \brief The core download scheduler. {{{ * * This class represents an ongoing download. It manages the lists * of active and pending downloads and handles setting up and tearing @@ -164,7 +163,7 @@ class pkgAcquire QueueAccess} QueueMode; /** \brief If \b true, debugging information will be dumped to std::clog. */ - bool Debug; + bool const Debug; /** \brief If \b true, a download is currently in progress. */ bool Running; @@ -335,15 +334,22 @@ class pkgAcquire */ double PartialPresent(); - /** \brief Construct a new pkgAcquire. + /** \brief Delayed constructor * - * \param Log The progress indicator associated with this - * download, or \b NULL for none. This object is not owned by the + * \param Progress indicator associated with this download or + * \b NULL for none. This object is not owned by the * download process and will not be deleted when the pkgAcquire * object is destroyed. Naturally, it should live for at least as * long as the pkgAcquire object does. + * \param Lock defines a lock file that should be acquired to ensure + * only one Acquire class is in action at the time or an empty string + * if no lock file should be used. */ - pkgAcquire(pkgAcquireStatus *Log = 0); + bool Setup(pkgAcquireStatus *Progress = NULL, string const &Lock = ""); + + /** \brief Construct a new pkgAcquire. */ + pkgAcquire(pkgAcquireStatus *Log) __deprecated; + pkgAcquire(); /** \brief Destroy this pkgAcquire object. * @@ -351,6 +357,18 @@ class pkgAcquire * this download. */ virtual ~pkgAcquire(); + + private: + /** \brief FD of the Lock file we acquire in Setup (if any) */ + int LockFD; + + /** \brief Ensure the existence of the given Path + * + * \param Parent directory of the Path directory - a trailing + * /apt/ will be removed before CreateDirectory call. + * \param Path which should exist after (successful) call + */ + bool CheckDirectory(string const &Parent, string const &Path) const; }; /** \brief Represents a single download source from which an item @@ -369,8 +387,8 @@ struct pkgAcquire::ItemDesc /** brief The underlying item which is to be downloaded. */ Item *Owner; }; - -/** \brief A single download queue in a pkgAcquire object. + /*}}}*/ +/** \brief A single download queue in a pkgAcquire object. {{{ * * \todo Why so many protected values? */ @@ -440,8 +458,12 @@ class pkgAcquire::Queue public: - /** \brief Insert the given fetch request into this queue. */ - void Enqueue(ItemDesc &Item); + /** \brief Insert the given fetch request into this queue. + * + * \return \b true if the queuing was successful. May return + * \b false if the Item is already in the queue + */ + bool Enqueue(ItemDesc &Item); /** \brief Remove all fetch requests for the given item from this queue. * @@ -527,8 +549,8 @@ class pkgAcquire::Queue */ ~Queue(); }; - -/** \brief Iterates over all the URIs being fetched by a pkgAcquire object. */ + /*}}}*/ +/** \brief Iterates over all the URIs being fetched by a pkgAcquire object. {{{*/ class pkgAcquire::UriIterator { /** The next queue to iterate over. */ @@ -538,7 +560,7 @@ class pkgAcquire::UriIterator public: - inline void operator ++() {operator ++();}; + inline void operator ++() {operator ++(0);}; void operator ++(int) { @@ -567,8 +589,8 @@ class pkgAcquire::UriIterator } } }; - -/** \brief Information about the properties of a single acquire method. */ + /*}}}*/ +/** \brief Information about the properties of a single acquire method. {{{*/ struct pkgAcquire::MethodConfig { /** \brief The next link on the acquire method list. @@ -620,8 +642,8 @@ struct pkgAcquire::MethodConfig */ MethodConfig(); }; - -/** \brief A monitor object for downloads controlled by the pkgAcquire class. + /*}}}*/ +/** \brief A monitor object for downloads controlled by the pkgAcquire class. {{{ * * \todo Why protected members? * @@ -761,7 +783,7 @@ class pkgAcquireStatus pkgAcquireStatus(); virtual ~pkgAcquireStatus() {}; }; - + /*}}}*/ /** @} */ #endif