rename the 'universe' to 'scenario' to reflect the naming in the draft
[ntk/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 <apt-pkg/edspindexfile.h>
10 #include <apt-pkg/edsplistparser.h>
11 #include <apt-pkg/sourcelist.h>
12 #include <apt-pkg/configuration.h>
13 #include <apt-pkg/progress.h>
14 #include <apt-pkg/error.h>
15 #include <apt-pkg/strutl.h>
16 #include <apt-pkg/acquire-item.h>
17
18 #include <sys/stat.h>
19 /*}}}*/
20
21 // edspIndex::edspIndex - Constructor /*{{{*/
22 // ---------------------------------------------------------------------
23 /* */
24 edspIndex::edspIndex(string File) : debStatusIndex(File)
25 {
26 }
27 /*}}}*/
28 // StatusIndex::Merge - Load the index file into a cache /*{{{*/
29 bool edspIndex::Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const
30 {
31 FileFd Pkg;
32 if (File != "stdin")
33 Pkg.Open(File, FileFd::ReadOnly);
34 else
35 Pkg.OpenDescriptor(STDIN_FILENO, FileFd::ReadOnly);
36 if (_error->PendingError() == true)
37 return false;
38 edspListParser Parser(&Pkg);
39 if (_error->PendingError() == true)
40 return false;
41
42 if (Prog != NULL)
43 Prog->SubProgress(0,File);
44 if (Gen.SelectFile(File,string(),*this) == false)
45 return _error->Error("Problem with SelectFile %s",File.c_str());
46
47 // Store the IMS information
48 pkgCache::PkgFileIterator CFile = Gen.GetCurFile();
49 struct stat St;
50 if (fstat(Pkg.Fd(),&St) != 0)
51 return _error->Errno("fstat","Failed to stat");
52 CFile->Size = St.st_size;
53 CFile->mtime = St.st_mtime;
54 CFile->Archive = Gen.WriteUniqString("edsp::scenario");
55
56 if (Gen.MergeList(Parser) == false)
57 return _error->Error("Problem with MergeList %s",File.c_str());
58 return true;
59 }
60 /*}}}*/
61 // Index File types for APT /*{{{*/
62 class edspIFType: public pkgIndexFile::Type
63 {
64 public:
65 virtual pkgRecords::Parser *CreatePkgParser(pkgCache::PkgFileIterator File) const
66 {
67 // we don't have a record parser for this type as the file is not presistent
68 return NULL;
69 };
70 edspIFType() {Label = "EDSP scenario file";};
71 };
72 static edspIFType _apt_Universe;
73
74 const pkgIndexFile::Type *edspIndex::GetType() const
75 {
76 return &_apt_Universe;
77 }
78 /*}}}*/