12
12
#include <apt-pkg/edsplistparser.h>
13
13
#include <apt-pkg/error.h>
14
14
#include <apt-pkg/fileutl.h>
15
#include <apt-pkg/progress.h>
16
#include <apt-pkg/debindexfile.h>
17
15
#include <apt-pkg/indexfile.h>
18
#include <apt-pkg/mmap.h>
19
16
#include <apt-pkg/pkgcache.h>
20
#include <apt-pkg/cacheiterators.h>
21
#include <apt-pkg/pkgcachegen.h>
22
17
#include <apt-pkg/pkgrecords.h>
24
19
#include <stddef.h>
29
// edspIndex::edspIndex - Constructor /*{{{*/
30
// ---------------------------------------------------------------------
32
edspIndex::edspIndex(std::string File) : debStatusIndex(File)
36
// StatusIndex::Merge - Load the index file into a cache /*{{{*/
37
bool edspIndex::Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const
41
Pkg.Open(File, FileFd::ReadOnly);
43
Pkg.OpenDescriptor(STDIN_FILENO, FileFd::ReadOnly);
44
if (_error->PendingError() == true)
46
edspListParser Parser(&Pkg);
47
if (_error->PendingError() == true)
51
Prog->SubProgress(0,File);
52
if (Gen.SelectFile(File,std::string(),*this) == false)
53
return _error->Error("Problem with SelectFile %s",File.c_str());
55
// Store the IMS information
56
pkgCache::PkgFileIterator CFile = Gen.GetCurFile();
57
CFile->Size = Pkg.FileSize();
58
CFile->mtime = Pkg.ModificationTime();
59
map_stringitem_t const storage = Gen.StoreString(pkgCacheGenerator::MIXED, "edsp::scenario");
60
CFile->Archive = storage;
62
if (Gen.MergeList(Parser) == false)
63
return _error->Error("Problem with MergeList %s",File.c_str());
25
edspIndex::edspIndex(std::string const &File) : pkgDebianIndexRealFile(File, true), d(NULL)
28
std::string edspIndex::GetComponent() const
32
std::string edspIndex::GetArchitecture() const
36
bool edspIndex::HasPackages() const
40
bool edspIndex::Exists() const
44
uint8_t edspIndex::GetIndexFlags() const
48
bool edspIndex::OpenListFile(FileFd &Pkg, std::string const &FileName)
50
if (FileName.empty() == false && FileName != "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());
56
pkgCacheListParser * edspIndex::CreateListParser(FileFd &Pkg)
58
if (Pkg.IsOpen() == false)
60
_error->PushToStack();
61
pkgCacheListParser * const Parser = new edspListParser(&Pkg);
62
bool const newError = _error->PendingError();
63
_error->MergeWithStack();
64
return newError ? NULL : Parser;
67
68
// Index File types for APT /*{{{*/
68
class edspIFType: public pkgIndexFile::Type
69
class APT_HIDDEN edspIFType: public pkgIndexFile::Type
71
virtual pkgRecords::Parser *CreatePkgParser(pkgCache::PkgFileIterator) const
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
76
77
edspIFType() {Label = "EDSP scenario file";};
78
static edspIFType _apt_Universe;
79
APT_HIDDEN edspIFType _apt_Edsp;
80
81
const pkgIndexFile::Type *edspIndex::GetType() const
82
return &_apt_Universe;
87
edspIndex::~edspIndex() {}