acquire-item.cc 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. // -*- mode: cpp; mode: fold -*-
  2. // Description /*{{{*/
  3. // $Id: acquire-item.cc,v 1.2 1998/10/20 02:39:12 jgg Exp $
  4. /* ######################################################################
  5. Acquire Item - Item to acquire
  6. Each item can download to exactly one file at a time. This means you
  7. cannot create an item that fetches two uri's to two files at the same
  8. time. The pkgAcqIndex class creates a second class upon instantiation
  9. to fetch the other index files because of this.
  10. ##################################################################### */
  11. /*}}}*/
  12. // Include Files /*{{{*/
  13. #ifdef __GNUG__
  14. #pragma implementation "apt-pkg/acquire-item.h"
  15. #endif
  16. #include <apt-pkg/acquire-item.h>
  17. #include <apt-pkg/configuration.h>
  18. #include <strutl.h>
  19. /*}}}*/
  20. // Acquire::Item::Item - Constructor /*{{{*/
  21. // ---------------------------------------------------------------------
  22. /* */
  23. pkgAcquire::Item::Item(pkgAcquire *Owner) : Owner(Owner), QueueCounter(0)
  24. {
  25. Owner->Add(this);
  26. }
  27. /*}}}*/
  28. // Acquire::Item::~Item - Destructor /*{{{*/
  29. // ---------------------------------------------------------------------
  30. /* */
  31. pkgAcquire::Item::~Item()
  32. {
  33. Owner->Remove(this);
  34. }
  35. /*}}}*/
  36. // AcqIndex::AcqIndex - Constructor /*{{{*/
  37. // ---------------------------------------------------------------------
  38. /* The package file is added to the queue and a second class is
  39. instantiated to fetch the revision file */
  40. pkgAcqIndex::pkgAcqIndex(pkgAcquire *Owner,const pkgSourceList::Item *Location) :
  41. Item(Owner), Location(Location)
  42. {
  43. QueueURI(Location->PackagesURI() + ".gz");
  44. Description = Location->PackagesInfo();
  45. new pkgAcqIndexRel(Owner,Location);
  46. }
  47. /*}}}*/
  48. // pkgAcqIndex::ToFile - File to write the download to /*{{{*/
  49. // ---------------------------------------------------------------------
  50. /* */
  51. string pkgAcqIndex::ToFile()
  52. {
  53. string PartialDir = _config->FindFile("Dir::State::lists") + "/partial/";
  54. return PartialDir + URItoFileName(Location->PackagesURI());
  55. }
  56. /*}}}*/
  57. // AcqIndexRel::pkgAcqIndexRel - Constructor /*{{{*/
  58. // ---------------------------------------------------------------------
  59. /* The Release file is added to the queue */
  60. pkgAcqIndexRel::pkgAcqIndexRel(pkgAcquire *Owner,
  61. const pkgSourceList::Item *Location) :
  62. Item(Owner), Location(Location)
  63. {
  64. QueueURI(Location->ReleaseURI());
  65. Description = Location->ReleaseInfo();
  66. }
  67. /*}}}*/
  68. // AcqIndexRel::ToFile - File to write the download to /*{{{*/
  69. // ---------------------------------------------------------------------
  70. /* */
  71. string pkgAcqIndexRel::ToFile()
  72. {
  73. string PartialDir = _config->FindFile("Dir::State::lists") + "/partial/";
  74. return PartialDir + URItoFileName(Location->ReleaseURI());
  75. }
  76. /*}}}*/