+ // Shut down the items
+ for (Item **I = Items.begin(); I != Items.end(); I++)
+ (*I)->Finished();
+
+ if (_error->PendingError())
+ return Failed;
+ if (WasCancelled)
+ return Cancelled;
+ return Continue;
+}
+ /*}}}*/
+// Acquire::Bump - Called when an item is dequeued /*{{{*/
+// ---------------------------------------------------------------------
+/* This routine bumps idle queues in hopes that they will be able to fetch
+ the dequeued item */
+void pkgAcquire::Bump()
+{
+ for (Queue *I = Queues; I != 0; I = I->Next)
+ I->Bump();
+}
+ /*}}}*/
+// Acquire::WorkerStep - Step to the next worker /*{{{*/
+// ---------------------------------------------------------------------
+/* Not inlined to advoid including acquire-worker.h */
+pkgAcquire::Worker *pkgAcquire::WorkerStep(Worker *I)
+{
+ return I->NextAcquire;
+};
+ /*}}}*/
+// Acquire::Clean - Cleans a directory /*{{{*/
+// ---------------------------------------------------------------------
+/* This is a bit simplistic, it looks at every file in the dir and sees
+ if it is part of the download set. */
+bool pkgAcquire::Clean(string Dir)
+{
+ DIR *D = opendir(Dir.c_str());
+ if (D == 0)
+ return _error->Errno("opendir",_("Unable to read %s"),Dir.c_str());
+
+ string StartDir = SafeGetCWD();
+ if (chdir(Dir.c_str()) != 0)
+ {
+ closedir(D);
+ return _error->Errno("chdir",_("Unable to change to %s"),Dir.c_str());
+ }
+
+ for (struct dirent *Dir = readdir(D); Dir != 0; Dir = readdir(D))
+ {
+ // Skip some files..
+ if (strcmp(Dir->d_name,"lock") == 0 ||
+ strcmp(Dir->d_name,"partial") == 0 ||
+ strcmp(Dir->d_name,".") == 0 ||
+ strcmp(Dir->d_name,"..") == 0)
+ continue;
+
+ // Look in the get list
+ vector<Item *>::iterator I = Items.begin();
+ for (; I != Items.end(); I++)
+ if (flNotDir((*I)->DestFile) == Dir->d_name)
+ break;
+
+ // Nothing found, nuke it
+ if (I == Items.end())
+ unlink(Dir->d_name);
+ };
+
+ chdir(StartDir.c_str());
+ closedir(D);
+ return true;
+}
+ /*}}}*/
+// Acquire::TotalNeeded - Number of bytes to fetch /*{{{*/
+// ---------------------------------------------------------------------
+/* This is the total number of bytes needed */
+double pkgAcquire::TotalNeeded()
+{
+ double Total = 0;
+ for (pkgAcquire::Item **I = ItemsBegin(); I != ItemsEnd(); I++)
+ Total += (*I)->FileSize;
+ return Total;
+}
+ /*}}}*/
+// Acquire::FetchNeeded - Number of bytes needed to get /*{{{*/
+// ---------------------------------------------------------------------
+/* This is the number of bytes that is not local */
+double pkgAcquire::FetchNeeded()
+{
+ double Total = 0;
+ for (pkgAcquire::Item **I = ItemsBegin(); I != ItemsEnd(); I++)
+ if ((*I)->Local == false)
+ Total += (*I)->FileSize;
+ return Total;
+}
+ /*}}}*/
+// Acquire::PartialPresent - Number of partial bytes we already have /*{{{*/
+// ---------------------------------------------------------------------
+/* This is the number of bytes that is not local */
+double pkgAcquire::PartialPresent()
+{
+ double Total = 0;
+ for (pkgAcquire::Item **I = ItemsBegin(); I != ItemsEnd(); I++)
+ if ((*I)->Local == false)
+ Total += (*I)->PartialSize;
+ return Total;
+}
+ /*}}}*/
+// Acquire::UriBegin - Start iterator for the uri list /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+pkgAcquire::UriIterator pkgAcquire::UriBegin()
+{
+ return UriIterator(Queues);
+}
+ /*}}}*/
+// Acquire::UriEnd - End iterator for the uri list /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+pkgAcquire::UriIterator pkgAcquire::UriEnd()
+{
+ return UriIterator(0);