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