]>
Commit | Line | Data |
---|---|---|
f55ece0e AL |
1 | // -*- mode: cpp; mode: fold -*- |
2 | // Description /*{{{*/ | |
3b5421b4 | 3 | // $Id: pkgrecords.cc,v 1.3 1998/10/20 02:39:23 jgg Exp $ |
f55ece0e AL |
4 | /* ###################################################################### |
5 | ||
6 | Package Records - Allows access to complete package description records | |
7 | directly from the file. | |
8 | ||
9 | ##################################################################### */ | |
10 | /*}}}*/ | |
11 | // Include Files /*{{{*/ | |
12 | #ifdef __GNUG__ | |
13 | #pragma implementation "apt-pkg/pkgrecords.h" | |
14 | #endif | |
15 | #include <apt-pkg/pkgrecords.h> | |
16 | #include <apt-pkg/debrecords.h> | |
17 | #include <apt-pkg/error.h> | |
3164dff9 | 18 | #include <apt-pkg/configuration.h> |
f55ece0e AL |
19 | /*}}}*/ |
20 | ||
21 | // Records::pkgRecords - Constructor /*{{{*/ | |
22 | // --------------------------------------------------------------------- | |
23 | /* This will create the necessary structures to access the status files */ | |
24 | pkgRecords::pkgRecords(pkgCache &Cache) : Cache(Cache), Files(0) | |
25 | { | |
3b5421b4 | 26 | string ListDir = _config->FindFile("Dir::State::lists"); |
3164dff9 | 27 | |
f55ece0e AL |
28 | Files = new PkgFile[Cache.HeaderP->PackageFileCount]; |
29 | for (pkgCache::PkgFileIterator I = Cache.FileBegin(); | |
30 | I.end() == false; I++) | |
31 | { | |
3164dff9 AL |
32 | // We can not initialize if the cache is out of sync. |
33 | if (I.IsOk() == false) | |
34 | { | |
35 | _error->Error("Package file %s is out of sync.",I.FileName()); | |
36 | return; | |
37 | } | |
38 | ||
39 | // Create the file | |
40 | Files[I->ID].File = new FileFd(ListDir + I.FileName(),FileFd::ReadOnly); | |
f55ece0e AL |
41 | if (_error->PendingError() == true) |
42 | return; | |
3164dff9 AL |
43 | |
44 | // Create the parser | |
f55ece0e AL |
45 | Files[I->ID].Parse = new debRecordParser(*Files[I->ID].File); |
46 | if (_error->PendingError() == true) | |
47 | return; | |
48 | } | |
49 | } | |
50 | /*}}}*/ | |
51 | // Records::~pkgRecords - Destructor /*{{{*/ | |
52 | // --------------------------------------------------------------------- | |
53 | /* */ | |
54 | pkgRecords::~pkgRecords() | |
55 | { | |
56 | delete [] Files; | |
57 | } | |
58 | /*}}}*/ | |
59 | // Records::Lookup - Get a parser for the package version file /*{{{*/ | |
60 | // --------------------------------------------------------------------- | |
61 | /* */ | |
62 | pkgRecords::Parser &pkgRecords::Lookup(pkgCache::VerFileIterator &Ver) | |
63 | { | |
64 | PkgFile &File = Files[Ver.File()->ID]; | |
65 | File.Parse->Jump(Ver); | |
66 | ||
67 | return *File.Parse; | |
68 | } | |
69 | /*}}}*/ | |
70 | // Records::Pkgfile::~PkgFile - Destructor /*{{{*/ | |
71 | // --------------------------------------------------------------------- | |
72 | /* */ | |
73 | pkgRecords::PkgFile::~PkgFile() | |
74 | { | |
75 | delete Parse; | |
76 | delete File; | |
77 | } | |
78 | /*}}}*/ |