]>
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
)
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() {};
83 class TranslationWriter
87 std::set
<string
> Included
;
88 unsigned short RefCounter
;
91 void IncreaseRefCounter() { ++RefCounter
; };
92 unsigned short DecreaseRefCounter() { return (RefCounter
== 0) ? 0 : --RefCounter
; };
93 unsigned short GetRefCounter() const { return RefCounter
; };
94 bool DoPackage(string
const &Pkg
, string
const &Desc
, string
const &MD5
);
96 TranslationWriter(string
const &File
, string
const &TransCompress
, mode_t
const &Permissions
);
97 TranslationWriter() : Comp(NULL
), Output(NULL
), RefCounter(0) {};
101 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
;