]>
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 ##################################################################### */
16 #include <apt-pkg/hashes.h>
25 #include <sys/types.h>
30 #include "apt-ftparchive.h"
41 vector
<string
> Patterns
;
44 const char *OriginalPath
;
47 // Stuff for the delinker
50 static FTWScanner
*Owner
;
51 static int ScannerFTW(const char *File
,const struct stat
*sb
,int Flag
);
52 static int ScannerFile(const char *File
, bool const &ReadLink
);
54 bool Delink(string
&FileName
,const char *OriginalPath
,
55 unsigned long long &Bytes
,unsigned long long const &FileSize
);
57 inline void NewLine(unsigned const &Priority
)
59 if (ErrorPrinted
== false && Quiet
<= Priority
)
69 unsigned int DoHashes
;
71 unsigned long DeLinkLimit
;
72 string InternalPrefix
;
74 virtual bool DoPackage(string FileName
) = 0;
75 bool RecursiveScan(string
const &Dir
);
76 bool LoadFileList(string
const &BaseDir
,string
const &File
);
77 void ClearPatterns() { Patterns
.clear(); };
78 void AddPattern(string
const &Pattern
) { Patterns
.push_back(Pattern
); };
79 void AddPattern(char const *Pattern
) { Patterns
.push_back(Pattern
); };
80 void AddPatterns(std::vector
<std::string
> const &patterns
) { Patterns
.insert(Patterns
.end(), patterns
.begin(), patterns
.end()); };
81 bool SetExts(string
const &Vals
);
83 FTWScanner(FileFd
* const Output
, string
const &Arch
= string(), bool const IncludeArchAll
= true);
84 virtual ~FTWScanner();
89 class TranslationWriter
92 std::set
<string
> Included
;
96 bool DoPackage(string
const &Pkg
, string
const &Desc
, string
const &MD5
);
98 TranslationWriter(string
const &File
, string
const &TransCompress
, mode_t
const &Permissions
);
102 class PackagesWriter
: public FTWScanner
113 bool LongDescription
;
118 struct CacheDB::Stats
&Stats
;
119 TranslationWriter
* const 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
) APT_OVERRIDE
;
126 PackagesWriter(FileFd
* const Output
, TranslationWriter
* const TransWriter
, string
const &DB
,
127 string
const &Overrides
,
128 string
const &ExtOverrides
= "",
129 string
const &Arch
= "",
130 bool const IncludeArchAll
= true);
131 virtual ~PackagesWriter();
134 class ContentsWriter
: public FTWScanner
143 struct CacheDB::Stats
&Stats
;
146 bool DoPackage(string FileName
,string Package
);
147 virtual bool DoPackage(string FileName
) APT_OVERRIDE
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(FileFd
* const Output
, string
const &DB
, string
const &Arch
= string(),
155 bool const IncludeArchAll
= true);
156 virtual ~ContentsWriter() {};
159 class SourcesWriter
: public FTWScanner
165 unsigned long long BufSize
;
175 struct CacheDB::Stats
&Stats
;
177 virtual bool DoPackage(string FileName
) APT_OVERRIDE
;
179 SourcesWriter(FileFd
* const Output
, string
const &DB
,string
const &BOverrides
,string
const &SOverrides
,
180 string
const &ExtOverrides
=string());
181 virtual ~SourcesWriter() {free(Buffer
);};
184 class ReleaseWriter
: public FTWScanner
187 ReleaseWriter(FileFd
* const Output
, string
const &DB
);
188 virtual bool DoPackage(string FileName
) APT_OVERRIDE
;
197 HashStringList Hashes
;
198 // Limited by FileFd::Size()
199 unsigned long long size
;
203 map
<string
,struct CheckSum
> CheckSums
;