]>
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());
77 class TranslationWriter
81 std::set
<string
> Included
;
82 unsigned short RefCounter
;
85 void IncreaseRefCounter() { ++RefCounter
; };
86 unsigned short DecreaseRefCounter() { return (RefCounter
== 0) ? 0 : --RefCounter
; };
87 unsigned short GetRefCounter() const { return RefCounter
; };
88 bool DoPackage(string
const &Pkg
, string
const &Desc
, string
const &MD5
);
90 TranslationWriter(string
const &File
, string
const &TransCompress
, mode_t
const &Permissions
);
91 TranslationWriter() : Comp(NULL
), Output(NULL
), RefCounter(0) {};
95 class PackagesWriter
: public FTWScanner
109 bool LongDescription
;
115 struct CacheDB::Stats
&Stats
;
116 TranslationWriter
*TransWriter
;
118 inline bool ReadOverride(string
const &File
) {return Over
.ReadOverride(File
);};
119 inline bool ReadExtraOverride(string
const &File
)
120 {return Over
.ReadExtraOverride(File
);};
121 virtual bool DoPackage(string FileName
);
123 PackagesWriter(string
const &DB
,string
const &Overrides
,string
const &ExtOverrides
=string(),
124 string
const &Arch
=string());
125 virtual ~PackagesWriter() {};
128 class ContentsWriter
: public FTWScanner
138 struct CacheDB::Stats
&Stats
;
141 bool DoPackage(string FileName
,string Package
);
142 virtual bool DoPackage(string FileName
)
143 {return DoPackage(FileName
,string());};
144 bool ReadFromPkgs(string
const &PkgFile
,string
const &PkgCompress
);
146 void Finish() {Gen
.Print(Output
);};
147 inline bool ReadyDB(string
const &DB
) {return Db
.ReadyDB(DB
);};
149 ContentsWriter(string
const &DB
, string
const &Arch
= string());
150 virtual ~ContentsWriter() {};
153 class SourcesWriter
: public FTWScanner
158 unsigned long BufSize
;
168 struct CacheDB::Stats Stats
;
170 virtual bool DoPackage(string FileName
);
172 SourcesWriter(string
const &BOverrides
,string
const &SOverrides
,
173 string
const &ExtOverrides
=string());
174 virtual ~SourcesWriter() {free(Buffer
);};
177 class ReleaseWriter
: public FTWScanner
180 ReleaseWriter(string
const &DB
);
181 virtual bool DoPackage(string FileName
);
195 // Limited by FileFd::Size()
199 map
<string
,struct CheckSum
> CheckSums
;