]>
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 long &Bytes
,unsigned long long const &FileSize
);
53 inline void NewLine(unsigned const &Priority
)
55 if (ErrorPrinted
== false && Quiet
<= Priority
)
68 unsigned long DeLinkLimit
;
69 string InternalPrefix
;
71 virtual bool DoPackage(string FileName
) = 0;
72 bool RecursiveScan(string
const &Dir
);
73 bool LoadFileList(string
const &BaseDir
,string
const &File
);
74 void ClearPatterns() { Patterns
.clear(); };
75 void AddPattern(string
const &Pattern
) { Patterns
.push_back(Pattern
); };
76 void AddPattern(char const *Pattern
) { Patterns
.push_back(Pattern
); };
77 void AddPatterns(std::vector
<std::string
> const &patterns
) { Patterns
.insert(Patterns
.end(), patterns
.begin(), patterns
.end()); };
78 bool SetExts(string
const &Vals
);
80 FTWScanner(string
const &Arch
= string());
81 virtual ~FTWScanner() {};
84 class TranslationWriter
88 std::set
<string
> Included
;
89 unsigned short RefCounter
;
92 void IncreaseRefCounter() { ++RefCounter
; };
93 unsigned short DecreaseRefCounter() { return (RefCounter
== 0) ? 0 : --RefCounter
; };
94 unsigned short GetRefCounter() const { return RefCounter
; };
95 bool DoPackage(string
const &Pkg
, string
const &Desc
, string
const &MD5
);
97 TranslationWriter(string
const &File
, string
const &TransCompress
, mode_t
const &Permissions
);
98 TranslationWriter() : Comp(NULL
), Output(NULL
), RefCounter(0) {};
102 class PackagesWriter
: public FTWScanner
113 bool LongDescription
;
119 struct CacheDB::Stats
&Stats
;
120 TranslationWriter
*TransWriter
;
122 inline bool ReadOverride(string
const &File
) {return Over
.ReadOverride(File
);};
123 inline bool ReadExtraOverride(string
const &File
)
124 {return Over
.ReadExtraOverride(File
);};
125 virtual bool DoPackage(string FileName
);
127 PackagesWriter(string
const &DB
,string
const &Overrides
,string
const &ExtOverrides
=string(),
128 string
const &Arch
=string());
129 virtual ~PackagesWriter() {};
132 class ContentsWriter
: public FTWScanner
142 struct CacheDB::Stats
&Stats
;
145 bool DoPackage(string FileName
,string Package
);
146 virtual bool DoPackage(string FileName
)
147 {return DoPackage(FileName
,string());};
148 bool ReadFromPkgs(string
const &PkgFile
,string
const &PkgCompress
);
150 void Finish() {Gen
.Print(Output
);};
151 inline bool ReadyDB(string
const &DB
) {return Db
.ReadyDB(DB
);};
153 ContentsWriter(string
const &DB
, string
const &Arch
= string());
154 virtual ~ContentsWriter() {};
157 class SourcesWriter
: public FTWScanner
162 unsigned long long BufSize
;
172 struct CacheDB::Stats Stats
;
174 virtual bool DoPackage(string FileName
);
176 SourcesWriter(string
const &BOverrides
,string
const &SOverrides
,
177 string
const &ExtOverrides
=string());
178 virtual ~SourcesWriter() {free(Buffer
);};
181 class ReleaseWriter
: public FTWScanner
184 ReleaseWriter(string
const &DB
);
185 virtual bool DoPackage(string FileName
);
200 // Limited by FileFd::Size()
201 unsigned long long size
;
204 map
<string
,struct CheckSum
> CheckSums
;