]>
git.saurik.com Git - apt.git/blob - apt-pkg/pkgrecords.cc
1 // -*- mode: cpp; mode: fold -*-
3 // $Id: pkgrecords.cc,v 1.3 1998/10/20 02:39:23 jgg Exp $
4 /* ######################################################################
6 Package Records - Allows access to complete package description records
7 directly from the file.
9 ##################################################################### */
11 // Include Files /*{{{*/
13 #pragma implementation "apt-pkg/pkgrecords.h"
15 #include <apt-pkg/pkgrecords.h>
16 #include <apt-pkg/debrecords.h>
17 #include <apt-pkg/error.h>
18 #include <apt-pkg/configuration.h>
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)
26 string ListDir
= _config
->FindFile("Dir::State::lists");
28 Files
= new PkgFile
[Cache
.HeaderP
->PackageFileCount
];
29 for (pkgCache::PkgFileIterator I
= Cache
.FileBegin();
30 I
.end() == false; I
++)
32 // We can not initialize if the cache is out of sync.
33 if (I
.IsOk() == false)
35 _error
->Error("Package file %s is out of sync.",I
.FileName());
40 Files
[I
->ID
].File
= new FileFd(ListDir
+ I
.FileName(),FileFd::ReadOnly
);
41 if (_error
->PendingError() == true)
45 Files
[I
->ID
].Parse
= new debRecordParser(*Files
[I
->ID
].File
);
46 if (_error
->PendingError() == true)
51 // Records::~pkgRecords - Destructor /*{{{*/
52 // ---------------------------------------------------------------------
54 pkgRecords::~pkgRecords()
59 // Records::Lookup - Get a parser for the package version file /*{{{*/
60 // ---------------------------------------------------------------------
62 pkgRecords::Parser
&pkgRecords::Lookup(pkgCache::VerFileIterator
&Ver
)
64 PkgFile
&File
= Files
[Ver
.File()->ID
];
65 File
.Parse
->Jump(Ver
);
70 // Records::Pkgfile::~PkgFile - Destructor /*{{{*/
71 // ---------------------------------------------------------------------
73 pkgRecords::PkgFile::~PkgFile()