]>
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 void AddPattern(char const *Pattern
) { Patterns
.push_back(Pattern
); };
73 void AddPatterns(std::vector
<std::string
> const &patterns
) { Patterns
.insert(Patterns
.end(), patterns
.begin(), patterns
.end()); };
74 bool SetExts(string
const &Vals
);
76 FTWScanner(string
const &Arch
= string());
77 virtual ~FTWScanner() {};
80 class TranslationWriter
84 std::set
<string
> Included
;
85 unsigned short RefCounter
;
88 void IncreaseRefCounter() { ++RefCounter
; };
89 unsigned short DecreaseRefCounter() { return (RefCounter
== 0) ? 0 : --RefCounter
; };
90 unsigned short GetRefCounter() const { return RefCounter
; };
91 bool DoPackage(string
const &Pkg
, string
const &Desc
, string
const &MD5
);
93 TranslationWriter(string
const &File
, string
const &TransCompress
, mode_t
const &Permissions
);
94 TranslationWriter() : Comp(NULL
), Output(NULL
), RefCounter(0) {};
98 class PackagesWriter
: public FTWScanner
112 bool LongDescription
;
118 struct CacheDB::Stats
&Stats
;
119 TranslationWriter
*TransWriter
;
121 inline bool ReadOverride(string
const &File
) {return Over
.ReadOverride(File
);};
122 inline bool ReadExtraOverride(string
const &File
)
123 {return Over
.ReadExtraOverride(File
);};
124 virtual bool DoPackage(string FileName
);
126 PackagesWriter(string
const &DB
,string
const &Overrides
,string
const &ExtOverrides
=string(),
127 string
const &Arch
=string());
128 virtual ~PackagesWriter() {};
131 class ContentsWriter
: public FTWScanner
141 struct CacheDB::Stats
&Stats
;
144 bool DoPackage(string FileName
,string Package
);
145 virtual bool DoPackage(string FileName
)
146 {return DoPackage(FileName
,string());};
147 bool ReadFromPkgs(string
const &PkgFile
,string
const &PkgCompress
);
149 void Finish() {Gen
.Print(Output
);};
150 inline bool ReadyDB(string
const &DB
) {return Db
.ReadyDB(DB
);};
152 ContentsWriter(string
const &DB
, string
const &Arch
= string());
153 virtual ~ContentsWriter() {};
156 class SourcesWriter
: public FTWScanner
161 unsigned long BufSize
;
171 struct CacheDB::Stats Stats
;
173 virtual bool DoPackage(string FileName
);
175 SourcesWriter(string
const &BOverrides
,string
const &SOverrides
,
176 string
const &ExtOverrides
=string());
177 virtual ~SourcesWriter() {free(Buffer
);};
180 class ReleaseWriter
: public FTWScanner
183 ReleaseWriter(string
const &DB
);
184 virtual bool DoPackage(string FileName
);
198 // Limited by FileFd::Size()
202 map
<string
,struct CheckSum
> CheckSums
;