]> git.saurik.com Git - apt.git/blob - apt-pkg/pkgrecords.cc
b3105da4444f2eaa7b364d49d178a271a123fd8b
[apt.git] / apt-pkg / pkgrecords.cc
1 // -*- mode: cpp; mode: fold -*-
2 // Description /*{{{*/
3 // $Id: pkgrecords.cc,v 1.1 1998/08/09 00:51:35 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 /*}}}*/
19
20 // Records::pkgRecords - Constructor /*{{{*/
21 // ---------------------------------------------------------------------
22 /* This will create the necessary structures to access the status files */
23 pkgRecords::pkgRecords(pkgCache &Cache) : Cache(Cache), Files(0)
24 {
25 Files = new PkgFile[Cache.HeaderP->PackageFileCount];
26 for (pkgCache::PkgFileIterator I = Cache.FileBegin();
27 I.end() == false; I++)
28 {
29 Files[I->ID].File = new FileFd(I.FileName(),FileFd::ReadOnly);
30 if (_error->PendingError() == true)
31 return;
32 Files[I->ID].Parse = new debRecordParser(*Files[I->ID].File);
33 if (_error->PendingError() == true)
34 return;
35 }
36 }
37 /*}}}*/
38 // Records::~pkgRecords - Destructor /*{{{*/
39 // ---------------------------------------------------------------------
40 /* */
41 pkgRecords::~pkgRecords()
42 {
43 delete [] Files;
44 }
45 /*}}}*/
46 // Records::Lookup - Get a parser for the package version file /*{{{*/
47 // ---------------------------------------------------------------------
48 /* */
49 pkgRecords::Parser &pkgRecords::Lookup(pkgCache::VerFileIterator &Ver)
50 {
51 PkgFile &File = Files[Ver.File()->ID];
52 File.Parse->Jump(Ver);
53
54 return *File.Parse;
55 }
56 /*}}}*/
57 // Records::Pkgfile::~PkgFile - Destructor /*{{{*/
58 // ---------------------------------------------------------------------
59 /* */
60 pkgRecords::PkgFile::~PkgFile()
61 {
62 delete Parse;
63 delete File;
64 }
65 /*}}}*/