edspindexfile.cc 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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/error.h>
  13. #include <apt-pkg/fileutl.h>
  14. #include <apt-pkg/progress.h>
  15. #include <apt-pkg/debindexfile.h>
  16. #include <apt-pkg/indexfile.h>
  17. #include <apt-pkg/mmap.h>
  18. #include <apt-pkg/pkgcache.h>
  19. #include <apt-pkg/cacheiterators.h>
  20. #include <apt-pkg/pkgcachegen.h>
  21. #include <apt-pkg/pkgrecords.h>
  22. #include <stddef.h>
  23. #include <unistd.h>
  24. #include <string>
  25. /*}}}*/
  26. // EDSP Index /*{{{*/
  27. edspIndex::edspIndex(std::string const &File) : pkgDebianIndexRealFile(File, true), d(NULL)
  28. {
  29. }
  30. std::string edspIndex::GetComponent() const
  31. {
  32. return "edsp";
  33. }
  34. std::string edspIndex::GetArchitecture() const
  35. {
  36. return std::string();
  37. }
  38. bool edspIndex::HasPackages() const
  39. {
  40. return true;
  41. }
  42. bool edspIndex::Exists() const
  43. {
  44. return true;
  45. }
  46. uint8_t edspIndex::GetIndexFlags() const
  47. {
  48. return 0;
  49. }
  50. bool edspIndex::OpenListFile(FileFd &Pkg, std::string const &FileName)
  51. {
  52. if (FileName.empty() == false && FileName != "stdin")
  53. return pkgDebianIndexRealFile::OpenListFile(Pkg, FileName);
  54. if (Pkg.OpenDescriptor(STDIN_FILENO, FileFd::ReadOnly) == false)
  55. return _error->Error("Problem opening %s",FileName.c_str());
  56. return true;
  57. }
  58. pkgCacheListParser * edspIndex::CreateListParser(FileFd &Pkg)
  59. {
  60. if (Pkg.IsOpen() == false)
  61. return NULL;
  62. _error->PushToStack();
  63. pkgCacheListParser * const Parser = new edspListParser(&Pkg);
  64. bool const newError = _error->PendingError();
  65. _error->MergeWithStack();
  66. return newError ? NULL : Parser;
  67. }
  68. /*}}}*/
  69. // Index File types for APT /*{{{*/
  70. class APT_HIDDEN edspIFType: public pkgIndexFile::Type
  71. {
  72. public:
  73. virtual pkgRecords::Parser *CreatePkgParser(pkgCache::PkgFileIterator const &) const APT_OVERRIDE
  74. {
  75. // we don't have a record parser for this type as the file is not presistent
  76. return NULL;
  77. };
  78. edspIFType() {Label = "EDSP scenario file";};
  79. };
  80. APT_HIDDEN edspIFType _apt_Edsp;
  81. const pkgIndexFile::Type *edspIndex::GetType() const
  82. {
  83. return &_apt_Edsp;
  84. }
  85. /*}}}*/
  86. edspIndex::~edspIndex() {}