edspindexfile.cc 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. // -*- mode: cpp; mode: fold -*-
  2. // Description /*{{{*/
  3. /* ######################################################################
  4. The scenario file is designed to work as an intermediate file between
  5. APT and the resolver. Its on propose very similar to a dpkg status file
  6. ##################################################################### */
  7. /*}}}*/
  8. // Include Files /*{{{*/
  9. #include <config.h>
  10. #include <apt-pkg/edspindexfile.h>
  11. #include <apt-pkg/edsplistparser.h>
  12. #include <apt-pkg/sourcelist.h>
  13. #include <apt-pkg/configuration.h>
  14. #include <apt-pkg/progress.h>
  15. #include <apt-pkg/error.h>
  16. #include <apt-pkg/strutl.h>
  17. #include <apt-pkg/fileutl.h>
  18. #include <apt-pkg/acquire-item.h>
  19. #include <sys/stat.h>
  20. /*}}}*/
  21. // edspIndex::edspIndex - Constructor /*{{{*/
  22. // ---------------------------------------------------------------------
  23. /* */
  24. edspIndex::edspIndex(std::string File) : debStatusIndex(File)
  25. {
  26. }
  27. /*}}}*/
  28. // StatusIndex::Merge - Load the index file into a cache /*{{{*/
  29. bool edspIndex::Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const
  30. {
  31. FileFd Pkg;
  32. if (File != "stdin")
  33. Pkg.Open(File, FileFd::ReadOnly);
  34. else
  35. Pkg.OpenDescriptor(STDIN_FILENO, FileFd::ReadOnly);
  36. if (_error->PendingError() == true)
  37. return false;
  38. edspListParser Parser(&Pkg);
  39. if (_error->PendingError() == true)
  40. return false;
  41. if (Prog != NULL)
  42. Prog->SubProgress(0,File);
  43. if (Gen.SelectFile(File,std::string(),*this) == false)
  44. return _error->Error("Problem with SelectFile %s",File.c_str());
  45. // Store the IMS information
  46. pkgCache::PkgFileIterator CFile = Gen.GetCurFile();
  47. CFile->Size = Pkg.FileSize();
  48. CFile->mtime = Pkg.ModificationTime();
  49. map_ptrloc const storage = Gen.WriteUniqString("edsp::scenario");
  50. CFile->Archive = storage;
  51. if (Gen.MergeList(Parser) == false)
  52. return _error->Error("Problem with MergeList %s",File.c_str());
  53. return true;
  54. }
  55. /*}}}*/
  56. // Index File types for APT /*{{{*/
  57. class edspIFType: public pkgIndexFile::Type
  58. {
  59. public:
  60. virtual pkgRecords::Parser *CreatePkgParser(pkgCache::PkgFileIterator File) const
  61. {
  62. // we don't have a record parser for this type as the file is not presistent
  63. return NULL;
  64. };
  65. edspIFType() {Label = "EDSP scenario file";};
  66. };
  67. static edspIFType _apt_Universe;
  68. const pkgIndexFile::Type *edspIndex::GetType() const
  69. {
  70. return &_apt_Universe;
  71. }
  72. /*}}}*/