]>
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 ##################################################################### */
26 #include "apt-ftparchive.h"
37 vector
<string
> Patterns
;
39 const char *OriginalPath
;
42 // Stuff for the delinker
45 static FTWScanner
*Owner
;
46 static int ScannerFTW(const char *File
,const struct stat
*sb
,int Flag
);
47 static int ScannerFile(const char *File
, bool const &ReadLink
);
49 bool Delink(string
&FileName
,const char *OriginalPath
,
50 unsigned long long &Bytes
,unsigned long long const &FileSize
);
52 inline void NewLine(unsigned const &Priority
)
54 if (ErrorPrinted
== false && Quiet
<= Priority
)
67 unsigned long DeLinkLimit
;
68 string InternalPrefix
;
70 virtual bool DoPackage(string FileName
) = 0;
71 bool RecursiveScan(string
const &Dir
);
72 bool LoadFileList(string
const &BaseDir
,string
const &File
);
73 void ClearPatterns() { Patterns
.clear(); };
74 void AddPattern(string
const &Pattern
) { Patterns
.push_back(Pattern
); };
75 void AddPattern(char const *Pattern
) { Patterns
.push_back(Pattern
); };
76 void AddPatterns(std::vector
<std::string
> const &patterns
) { Patterns
.insert(Patterns
.end(), patterns
.begin(), patterns
.end()); };
77 bool SetExts(string
const &Vals
);
79 FTWScanner(string
const &Arch
= string());
80 virtual ~FTWScanner() {};
85 class TranslationWriter
89 std::set
<string
> Included
;
90 unsigned short RefCounter
;
93 void IncreaseRefCounter() { ++RefCounter
; };
94 unsigned short DecreaseRefCounter() { return (RefCounter
== 0) ? 0 : --RefCounter
; };
95 unsigned short GetRefCounter() const { return RefCounter
; };
96 bool DoPackage(string
const &Pkg
, string
const &Desc
, string
const &MD5
);
98 TranslationWriter(string
const &File
, string
const &TransCompress
, mode_t
const &Permissions
);
99 TranslationWriter() : Comp(NULL
), Output(NULL
), RefCounter(0) {};
100 ~TranslationWriter();
103 class PackagesWriter
: public FTWScanner
114 bool LongDescription
;
120 struct CacheDB::Stats
&Stats
;
121 TranslationWriter
*TransWriter
;
123 inline bool ReadOverride(string
const &File
) {return Over
.ReadOverride(File
);};
124 inline bool ReadExtraOverride(string
const &File
)
125 {return Over
.ReadExtraOverride(File
);};
126 virtual bool DoPackage(string FileName
);
128 PackagesWriter(string
const &DB
,string
const &Overrides
,string
const &ExtOverrides
=string(),
129 string
const &Arch
=string());
130 virtual ~PackagesWriter() {};
133 class ContentsWriter
: public FTWScanner
143 struct CacheDB::Stats
&Stats
;
146 bool DoPackage(string FileName
,string Package
);
147 virtual bool DoPackage(string FileName
)
148 {return DoPackage(FileName
,string());};
149 bool ReadFromPkgs(string
const &PkgFile
,string
const &PkgCompress
);
151 void Finish() {Gen
.Print(Output
);};
152 inline bool ReadyDB(string
const &DB
) {return Db
.ReadyDB(DB
);};
154 ContentsWriter(string
const &DB
, string
const &Arch
= string());
155 virtual ~ContentsWriter() {};
158 class SourcesWriter
: public FTWScanner
163 unsigned long long BufSize
;
173 struct CacheDB::Stats Stats
;
175 virtual bool DoPackage(string FileName
);
177 SourcesWriter(string
const &BOverrides
,string
const &SOverrides
,
178 string
const &ExtOverrides
=string());
179 virtual ~SourcesWriter() {free(Buffer
);};
182 class ReleaseWriter
: public FTWScanner
185 ReleaseWriter(string
const &DB
);
186 virtual bool DoPackage(string FileName
);
201 // Limited by FileFd::Size()
202 unsigned long long size
;
205 map
<string
,struct CheckSum
> CheckSums
;