]>
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 ##################################################################### */
23 #include <sys/types.h>
28 #include "apt-ftparchive.h"
39 vector
<string
> Patterns
;
41 const char *OriginalPath
;
44 // Stuff for the delinker
47 static FTWScanner
*Owner
;
48 static int ScannerFTW(const char *File
,const struct stat
*sb
,int Flag
);
49 static int ScannerFile(const char *File
, bool const &ReadLink
);
51 bool Delink(string
&FileName
,const char *OriginalPath
,
52 unsigned long long &Bytes
,unsigned long long const &FileSize
);
54 inline void NewLine(unsigned const &Priority
)
56 if (ErrorPrinted
== false && Quiet
<= Priority
)
69 unsigned long DeLinkLimit
;
70 string InternalPrefix
;
72 virtual bool DoPackage(string FileName
) = 0;
73 bool RecursiveScan(string
const &Dir
);
74 bool LoadFileList(string
const &BaseDir
,string
const &File
);
75 void ClearPatterns() { Patterns
.clear(); };
76 void AddPattern(string
const &Pattern
) { Patterns
.push_back(Pattern
); };
77 void AddPattern(char const *Pattern
) { Patterns
.push_back(Pattern
); };
78 void AddPatterns(std::vector
<std::string
> const &patterns
) { Patterns
.insert(Patterns
.end(), patterns
.begin(), patterns
.end()); };
79 bool SetExts(string
const &Vals
);
81 FTWScanner(string
const &Arch
= string());
82 virtual ~FTWScanner() {};
87 class TranslationWriter
91 std::set
<string
> Included
;
92 unsigned short RefCounter
;
95 void IncreaseRefCounter() { ++RefCounter
; };
96 unsigned short DecreaseRefCounter() { return (RefCounter
== 0) ? 0 : --RefCounter
; };
97 unsigned short GetRefCounter() const { return RefCounter
; };
98 bool DoPackage(string
const &Pkg
, string
const &Desc
, string
const &MD5
);
100 TranslationWriter(string
const &File
, string
const &TransCompress
, mode_t
const &Permissions
);
101 TranslationWriter() : Comp(NULL
), Output(NULL
), RefCounter(0) {};
102 ~TranslationWriter();
105 class PackagesWriter
: public FTWScanner
116 bool LongDescription
;
122 struct CacheDB::Stats
&Stats
;
123 TranslationWriter
*TransWriter
;
125 inline bool ReadOverride(string
const &File
) {return Over
.ReadOverride(File
);};
126 inline bool ReadExtraOverride(string
const &File
)
127 {return Over
.ReadExtraOverride(File
);};
128 virtual bool DoPackage(string FileName
);
130 PackagesWriter(string
const &DB
,
131 string
const &Overrides
,
132 string
const &ExtOverrides
= "",
133 string
const &Arch
= "");
134 virtual ~PackagesWriter() {};
137 class ContentsWriter
: public FTWScanner
147 struct CacheDB::Stats
&Stats
;
150 bool DoPackage(string FileName
,string Package
);
151 virtual bool DoPackage(string FileName
)
152 {return DoPackage(FileName
,string());};
153 bool ReadFromPkgs(string
const &PkgFile
,string
const &PkgCompress
);
155 void Finish() {Gen
.Print(Output
);};
156 inline bool ReadyDB(string
const &DB
) {return Db
.ReadyDB(DB
);};
158 ContentsWriter(string
const &DB
, string
const &Arch
= string());
159 virtual ~ContentsWriter() {};
162 class SourcesWriter
: public FTWScanner
168 unsigned long long BufSize
;
179 struct CacheDB::Stats
&Stats
;
181 virtual bool DoPackage(string FileName
);
183 SourcesWriter(string
const &DB
,string
const &BOverrides
,string
const &SOverrides
,
184 string
const &ExtOverrides
=string());
185 virtual ~SourcesWriter() {free(Buffer
);};
188 class ReleaseWriter
: public FTWScanner
191 ReleaseWriter(string
const &DB
);
192 virtual bool DoPackage(string FileName
);
207 // Limited by FileFd::Size()
208 unsigned long long size
;
211 map
<string
,struct CheckSum
> CheckSums
;