]>
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
;
43 const char *OriginalPath
;
46 // Stuff for the delinker
49 static FTWScanner
*Owner
;
50 static int ScannerFTW(const char *File
,const struct stat
*sb
,int Flag
);
51 static int ScannerFile(const char *File
, bool const &ReadLink
);
53 bool Delink(string
&FileName
,const char *OriginalPath
,
54 unsigned long long &Bytes
,unsigned long long const &FileSize
);
56 inline void NewLine(unsigned const &Priority
)
58 if (ErrorPrinted
== false && Quiet
<= Priority
)
66 unsigned int DoHashes
;
68 unsigned long DeLinkLimit
;
69 string InternalPrefix
;
71 virtual bool DoPackage(string FileName
) = 0;
72 bool RecursiveScan(string
const &Dir
);
73 bool LoadFileList(string
const &BaseDir
,string
const &File
);
74 void ClearPatterns() { Patterns
.clear(); };
75 void AddPattern(string
const &Pattern
) { Patterns
.push_back(Pattern
); };
76 void AddPattern(char const *Pattern
) { Patterns
.push_back(Pattern
); };
77 void AddPatterns(std::vector
<std::string
> const &patterns
) { Patterns
.insert(Patterns
.end(), patterns
.begin(), patterns
.end()); };
78 bool SetExts(string
const &Vals
);
80 FTWScanner(string
const &Arch
= string());
81 virtual ~FTWScanner() {};
86 class TranslationWriter
90 std::set
<string
> Included
;
91 unsigned short RefCounter
;
94 void IncreaseRefCounter() { ++RefCounter
; };
95 unsigned short DecreaseRefCounter() { return (RefCounter
== 0) ? 0 : --RefCounter
; };
96 unsigned short GetRefCounter() const { return RefCounter
; };
97 bool DoPackage(string
const &Pkg
, string
const &Desc
, string
const &MD5
);
99 TranslationWriter(string
const &File
, string
const &TransCompress
, mode_t
const &Permissions
);
100 TranslationWriter() : Comp(NULL
), Output(NULL
), RefCounter(0) {};
101 ~TranslationWriter();
104 class PackagesWriter
: public FTWScanner
115 bool LongDescription
;
121 struct CacheDB::Stats
&Stats
;
122 TranslationWriter
*TransWriter
;
124 inline bool ReadOverride(string
const &File
) {return Over
.ReadOverride(File
);};
125 inline bool ReadExtraOverride(string
const &File
)
126 {return Over
.ReadExtraOverride(File
);};
127 virtual bool DoPackage(string FileName
);
129 PackagesWriter(string
const &DB
,
130 string
const &Overrides
,
131 string
const &ExtOverrides
= "",
132 string
const &Arch
= "");
133 virtual ~PackagesWriter() {};
136 class ContentsWriter
: public FTWScanner
146 struct CacheDB::Stats
&Stats
;
149 bool DoPackage(string FileName
,string Package
);
150 virtual bool DoPackage(string FileName
)
151 {return DoPackage(FileName
,string());};
152 bool ReadFromPkgs(string
const &PkgFile
,string
const &PkgCompress
);
154 void Finish() {Gen
.Print(Output
);};
155 inline bool ReadyDB(string
const &DB
) {return Db
.ReadyDB(DB
);};
157 ContentsWriter(string
const &DB
, string
const &Arch
= string());
158 virtual ~ContentsWriter() {};
161 class SourcesWriter
: public FTWScanner
167 unsigned long long BufSize
;
178 struct CacheDB::Stats
&Stats
;
180 virtual bool DoPackage(string FileName
);
182 SourcesWriter(string
const &DB
,string
const &BOverrides
,string
const &SOverrides
,
183 string
const &ExtOverrides
=string());
184 virtual ~SourcesWriter() {free(Buffer
);};
187 class ReleaseWriter
: public FTWScanner
190 ReleaseWriter(string
const &DB
);
191 virtual bool DoPackage(string FileName
);
201 HashStringList Hashes
;
202 // Limited by FileFd::Size()
203 unsigned long long size
;
207 map
<string
,struct CheckSum
> CheckSums
;