]> git.saurik.com Git - apt.git/blob - apt-pkg/pkgrecords.cc
Fixed for new egcs
[apt.git] / apt-pkg / pkgrecords.cc
1 // -*- mode: cpp; mode: fold -*-
2 // Description /*{{{*/
3 // $Id: pkgrecords.cc,v 1.2 1998/08/19 06:16:10 jgg Exp $
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>
18 #include <apt-pkg/configuration.h>
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 {
26 string ListDir = _config->FindDir("Dir::State::lists");
27
28 Files = new PkgFile[Cache.HeaderP->PackageFileCount];
29 for (pkgCache::PkgFileIterator I = Cache.FileBegin();
30 I.end() == false; I++)
31 {
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);
41 if (_error->PendingError() == true)
42 return;
43
44 // Create the parser
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 /*}}}*/