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