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