edspindexfile.cc 2.3 KB

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