]> git.saurik.com Git - apt.git/blob - apt-pkg/edsp/edspindexfile.cc
Set STRIP_FROM_PATH for doxygen
[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/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>
23
24 #include <stddef.h>
25 #include <unistd.h>
26 #include <string>
27 /*}}}*/
28
29 // edspIndex::edspIndex - Constructor /*{{{*/
30 // ---------------------------------------------------------------------
31 /* */
32 edspIndex::edspIndex(std::string File) : debStatusIndex(File)
33 {
34 }
35 /*}}}*/
36 // StatusIndex::Merge - Load the index file into a cache /*{{{*/
37 bool edspIndex::Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const
38 {
39 FileFd Pkg;
40 if (File != "stdin")
41 Pkg.Open(File, FileFd::ReadOnly);
42 else
43 Pkg.OpenDescriptor(STDIN_FILENO, FileFd::ReadOnly);
44 if (_error->PendingError() == true)
45 return false;
46 edspListParser Parser(&Pkg);
47 if (_error->PendingError() == true)
48 return false;
49
50 if (Prog != NULL)
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());
54
55 // Store the IMS information
56 pkgCache::PkgFileIterator CFile = Gen.GetCurFile();
57 CFile->Size = Pkg.FileSize();
58 CFile->mtime = Pkg.ModificationTime();
59 map_ptrloc const storage = Gen.WriteUniqString("edsp::scenario");
60 CFile->Archive = storage;
61
62 if (Gen.MergeList(Parser) == false)
63 return _error->Error("Problem with MergeList %s",File.c_str());
64 return true;
65 }
66 /*}}}*/
67 // Index File types for APT /*{{{*/
68 class edspIFType: public pkgIndexFile::Type
69 {
70 public:
71 virtual pkgRecords::Parser *CreatePkgParser(pkgCache::PkgFileIterator) const
72 {
73 // we don't have a record parser for this type as the file is not presistent
74 return NULL;
75 };
76 edspIFType() {Label = "EDSP scenario file";};
77 };
78 static edspIFType _apt_Universe;
79
80 const pkgIndexFile::Type *edspIndex::GetType() const
81 {
82 return &_apt_Universe;
83 }
84 /*}}}*/