1 // -*- mode: cpp; mode: fold -*-
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 ##################################################################### */
8 // Include Files /*{{{*/
11 #include <apt-pkg/edspindexfile.h>
12 #include <apt-pkg/edsplistparser.h>
13 #include <apt-pkg/error.h>
14 #include <apt-pkg/fileutl.h>
15 #include <apt-pkg/indexfile.h>
16 #include <apt-pkg/pkgcache.h>
17 #include <apt-pkg/pkgrecords.h>
24 // EDSP-like Index /*{{{*/
25 edspLikeIndex::edspLikeIndex(std::string
const &File
) : pkgDebianIndexRealFile(File
, true)
28 std::string
edspLikeIndex::GetArchitecture() const
32 bool edspLikeIndex::HasPackages() const
36 bool edspLikeIndex::Exists() const
40 uint8_t edspLikeIndex::GetIndexFlags() const
44 bool edspLikeIndex::OpenListFile(FileFd
&Pkg
, std::string
const &FileName
)
46 if (FileName
.empty() == false && FileName
!= "/nonexistent/stdin")
47 return pkgDebianIndexRealFile::OpenListFile(Pkg
, FileName
);
48 if (Pkg
.OpenDescriptor(STDIN_FILENO
, FileFd::ReadOnly
) == false)
49 return _error
->Error("Problem opening %s",FileName
.c_str());
54 edspIndex::edspIndex(std::string
const &File
) : edspLikeIndex(File
)
57 std::string
edspIndex::GetComponent() const
61 pkgCacheListParser
* edspIndex::CreateListParser(FileFd
&Pkg
)
63 if (Pkg
.IsOpen() == false)
65 _error
->PushToStack();
66 pkgCacheListParser
* const Parser
= new edspListParser(&Pkg
);
67 bool const newError
= _error
->PendingError();
68 _error
->MergeWithStack();
69 return newError
? NULL
: Parser
;
73 eippIndex::eippIndex(std::string
const &File
) : edspLikeIndex(File
)
76 std::string
eippIndex::GetComponent() const
80 pkgCacheListParser
* eippIndex::CreateListParser(FileFd
&Pkg
)
82 if (Pkg
.IsOpen() == false)
84 _error
->PushToStack();
85 pkgCacheListParser
* const Parser
= new eippListParser(&Pkg
);
86 bool const newError
= _error
->PendingError();
87 _error
->MergeWithStack();
88 return newError
? NULL
: Parser
;
92 // Index File types for APT /*{{{*/
93 class APT_HIDDEN edspIFType
: public pkgIndexFile::Type
96 virtual pkgRecords::Parser
*CreatePkgParser(pkgCache::PkgFileIterator
const &) const APT_OVERRIDE
98 // we don't have a record parser for this type as the file is not presistent
101 edspIFType() {Label
= "EDSP scenario file";};
103 APT_HIDDEN edspIFType _apt_Edsp
;
104 const pkgIndexFile::Type
*edspIndex::GetType() const
109 class APT_HIDDEN eippIFType
: public pkgIndexFile::Type
112 virtual pkgRecords::Parser
*CreatePkgParser(pkgCache::PkgFileIterator
const &) const APT_OVERRIDE
114 // we don't have a record parser for this type as the file is not presistent
117 eippIFType() {Label
= "EIPP scenario file";};
119 APT_HIDDEN eippIFType _apt_Eipp
;
120 const pkgIndexFile::Type
*eippIndex::GetType() const
126 edspLikeIndex::~edspLikeIndex() {}
127 edspIndex::~edspIndex() {}
128 eippIndex::~eippIndex() {}