]>
Commit | Line | Data |
---|---|---|
6d38011b DK |
1 | // -*- mode: cpp; mode: fold -*- |
2 | // Description /*{{{*/ | |
3 | /* ###################################################################### | |
e0a78caa | 4 | The scenario file is designed to work as an intermediate file between |
6d38011b DK |
5 | APT and the resolver. Its on propose very similar to a dpkg status file |
6 | ##################################################################### */ | |
7 | /*}}}*/ | |
8 | // Include Files /*{{{*/ | |
ea542140 DK |
9 | #include <config.h> |
10 | ||
6d38011b DK |
11 | #include <apt-pkg/edspindexfile.h> |
12 | #include <apt-pkg/edsplistparser.h> | |
6d38011b | 13 | #include <apt-pkg/error.h> |
472ff00e | 14 | #include <apt-pkg/fileutl.h> |
453b82a3 DK |
15 | #include <apt-pkg/progress.h> |
16 | #include <apt-pkg/debindexfile.h> | |
17 | #include <apt-pkg/indexfile.h> | |
18 | #include <apt-pkg/mmap.h> | |
19 | #include <apt-pkg/pkgcache.h> | |
20 | #include <apt-pkg/cacheiterators.h> | |
21 | #include <apt-pkg/pkgcachegen.h> | |
22 | #include <apt-pkg/pkgrecords.h> | |
6d38011b | 23 | |
453b82a3 DK |
24 | #include <stddef.h> |
25 | #include <unistd.h> | |
26 | #include <string> | |
6d38011b DK |
27 | /*}}}*/ |
28 | ||
c9443c01 DK |
29 | // EDSP Index /*{{{*/ |
30 | edspIndex::edspIndex(std::string const &File) : pkgDebianIndexRealFile(File, true), d(NULL) | |
6d38011b DK |
31 | { |
32 | } | |
c9443c01 | 33 | std::string edspIndex::GetComponent() const |
6d38011b | 34 | { |
c9443c01 DK |
35 | return "edsp"; |
36 | } | |
37 | std::string edspIndex::GetArchitecture() const | |
38 | { | |
39 | return std::string(); | |
40 | } | |
41 | bool edspIndex::HasPackages() const | |
42 | { | |
43 | return true; | |
44 | } | |
45 | bool edspIndex::Exists() const | |
46 | { | |
47 | return true; | |
48 | } | |
49 | uint8_t edspIndex::GetIndexFlags() const | |
50 | { | |
51 | return 0; | |
52 | } | |
53 | bool edspIndex::OpenListFile(FileFd &Pkg, std::string const &FileName) | |
54 | { | |
55 | if (FileName.empty() == false && FileName != "stdin") | |
56 | return pkgDebianIndexRealFile::OpenListFile(Pkg, FileName); | |
57 | if (Pkg.OpenDescriptor(STDIN_FILENO, FileFd::ReadOnly) == false) | |
58 | return _error->Error("Problem opening %s",FileName.c_str()); | |
6d38011b | 59 | return true; |
c9443c01 DK |
60 | } |
61 | pkgCacheListParser * edspIndex::CreateListParser(FileFd &Pkg) | |
62 | { | |
63 | if (Pkg.IsOpen() == false) | |
64 | return NULL; | |
65 | _error->PushToStack(); | |
66 | pkgCacheListParser * const Parser = new edspListParser(&Pkg); | |
67 | bool const newError = _error->PendingError(); | |
68 | _error->MergeWithStack(); | |
69 | return newError ? NULL : Parser; | |
6d38011b DK |
70 | } |
71 | /*}}}*/ | |
c9443c01 | 72 | |
6d38011b | 73 | // Index File types for APT /*{{{*/ |
dce45dbe | 74 | class APT_HIDDEN edspIFType: public pkgIndexFile::Type |
6d38011b DK |
75 | { |
76 | public: | |
c9443c01 | 77 | virtual pkgRecords::Parser *CreatePkgParser(pkgCache::PkgFileIterator const &) const APT_OVERRIDE |
6d38011b DK |
78 | { |
79 | // we don't have a record parser for this type as the file is not presistent | |
80 | return NULL; | |
81 | }; | |
e0a78caa | 82 | edspIFType() {Label = "EDSP scenario file";}; |
6d38011b | 83 | }; |
c9443c01 | 84 | APT_HIDDEN edspIFType _apt_Edsp; |
6d38011b DK |
85 | |
86 | const pkgIndexFile::Type *edspIndex::GetType() const | |
87 | { | |
c9443c01 | 88 | return &_apt_Edsp; |
6d38011b DK |
89 | } |
90 | /*}}}*/ | |
c8a4ce6c DK |
91 | |
92 | edspIndex::~edspIndex() {} |