pkgrecords.cc 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. // -*- mode: cpp; mode: fold -*-
  2. // Description /*{{{*/
  3. // $Id: pkgrecords.cc,v 1.1 1998/08/09 00:51:35 jgg Exp $
  4. /* ######################################################################
  5. Package Records - Allows access to complete package description records
  6. directly from the file.
  7. ##################################################################### */
  8. /*}}}*/
  9. // Include Files /*{{{*/
  10. #ifdef __GNUG__
  11. #pragma implementation "apt-pkg/pkgrecords.h"
  12. #endif
  13. #include <apt-pkg/pkgrecords.h>
  14. #include <apt-pkg/debrecords.h>
  15. #include <apt-pkg/error.h>
  16. /*}}}*/
  17. // Records::pkgRecords - Constructor /*{{{*/
  18. // ---------------------------------------------------------------------
  19. /* This will create the necessary structures to access the status files */
  20. pkgRecords::pkgRecords(pkgCache &Cache) : Cache(Cache), Files(0)
  21. {
  22. Files = new PkgFile[Cache.HeaderP->PackageFileCount];
  23. for (pkgCache::PkgFileIterator I = Cache.FileBegin();
  24. I.end() == false; I++)
  25. {
  26. Files[I->ID].File = new FileFd(I.FileName(),FileFd::ReadOnly);
  27. if (_error->PendingError() == true)
  28. return;
  29. Files[I->ID].Parse = new debRecordParser(*Files[I->ID].File);
  30. if (_error->PendingError() == true)
  31. return;
  32. }
  33. }
  34. /*}}}*/
  35. // Records::~pkgRecords - Destructor /*{{{*/
  36. // ---------------------------------------------------------------------
  37. /* */
  38. pkgRecords::~pkgRecords()
  39. {
  40. delete [] Files;
  41. }
  42. /*}}}*/
  43. // Records::Lookup - Get a parser for the package version file /*{{{*/
  44. // ---------------------------------------------------------------------
  45. /* */
  46. pkgRecords::Parser &pkgRecords::Lookup(pkgCache::VerFileIterator &Ver)
  47. {
  48. PkgFile &File = Files[Ver.File()->ID];
  49. File.Parse->Jump(Ver);
  50. return *File.Parse;
  51. }
  52. /*}}}*/
  53. // Records::Pkgfile::~PkgFile - Destructor /*{{{*/
  54. // ---------------------------------------------------------------------
  55. /* */
  56. pkgRecords::PkgFile::~PkgFile()
  57. {
  58. delete Parse;
  59. delete File;
  60. }
  61. /*}}}*/