]>
git.saurik.com Git - apt.git/blob - ftparchive/writer.h
1 // -*- mode: cpp; mode: fold -*-
3 // $Id: writer.h,v 1.4.2.2 2003/12/26 22:55:43 mdz Exp $
4 /* ######################################################################
8 The file writer classes. These write various types of output, sources,
11 ##################################################################### */
25 #include "multicompress.h"
27 #include "apt-ftparchive.h"
38 vector
<string
> Patterns
;
40 const char *OriginalPath
;
43 // Stuff for the delinker
46 static FTWScanner
*Owner
;
47 static int ScannerFTW(const char *File
,const struct stat
*sb
,int Flag
);
48 static int ScannerFile(const char *File
, bool const &ReadLink
);
50 bool Delink(string
&FileName
,const char *OriginalPath
,
51 unsigned long &Bytes
,off_t
const &FileSize
);
53 inline void NewLine(unsigned const &Priority
)
55 if (ErrorPrinted
== false && Quiet
<= Priority
)
64 unsigned long DeLinkLimit
;
65 string InternalPrefix
;
67 virtual bool DoPackage(string FileName
) = 0;
68 bool RecursiveScan(string
const &Dir
);
69 bool LoadFileList(string
const &BaseDir
,string
const &File
);
70 void ClearPatterns() { Patterns
.clear(); };
71 void AddPattern(string
const &Pattern
) { Patterns
.push_back(Pattern
); };
72 bool SetExts(string
const &Vals
);
74 FTWScanner(string
const &Arch
= string());
75 virtual ~FTWScanner() {};
78 class TranslationWriter
82 std::set
<string
> Included
;
83 unsigned short RefCounter
;
86 void IncreaseRefCounter() { ++RefCounter
; };
87 unsigned short DecreaseRefCounter() { return (RefCounter
== 0) ? 0 : --RefCounter
; };
88 unsigned short GetRefCounter() const { return RefCounter
; };
89 bool DoPackage(string
const &Pkg
, string
const &Desc
, string
const &MD5
);
91 TranslationWriter(string
const &File
, string
const &TransCompress
, mode_t
const &Permissions
);
92 TranslationWriter() : Comp(NULL
), Output(NULL
), RefCounter(0) {};
96 class PackagesWriter
: public FTWScanner
110 bool LongDescription
;
116 struct CacheDB::Stats
&Stats
;
117 TranslationWriter
*TransWriter
;
119 inline bool ReadOverride(string
const &File
) {return Over
.ReadOverride(File
);};
120 inline bool ReadExtraOverride(string
const &File
)
121 {return Over
.ReadExtraOverride(File
);};
122 virtual bool DoPackage(string FileName
);
124 PackagesWriter(string
const &DB
,string
const &Overrides
,string
const &ExtOverrides
=string(),
125 string
const &Arch
=string());
126 virtual ~PackagesWriter() {};
129 class ContentsWriter
: public FTWScanner
139 struct CacheDB::Stats
&Stats
;
142 bool DoPackage(string FileName
,string Package
);
143 virtual bool DoPackage(string FileName
)
144 {return DoPackage(FileName
,string());};
145 bool ReadFromPkgs(string
const &PkgFile
,string
const &PkgCompress
);
147 void Finish() {Gen
.Print(Output
);};
148 inline bool ReadyDB(string
const &DB
) {return Db
.ReadyDB(DB
);};
150 ContentsWriter(string
const &DB
, string
const &Arch
= string());
151 virtual ~ContentsWriter() {};
154 class SourcesWriter
: public FTWScanner
159 unsigned long BufSize
;
169 struct CacheDB::Stats Stats
;
171 virtual bool DoPackage(string FileName
);
173 SourcesWriter(string
const &BOverrides
,string
const &SOverrides
,
174 string
const &ExtOverrides
=string());
175 virtual ~SourcesWriter() {free(Buffer
);};
178 class ReleaseWriter
: public FTWScanner
181 ReleaseWriter(string
const &DB
);
182 virtual bool DoPackage(string FileName
);
196 // Limited by FileFd::Size()
200 map
<string
,struct CheckSum
> CheckSums
;