]>
git.saurik.com Git - apt.git/blob - ftparchive/writer.h
98012beeeff656502208ca157edcd340238b97db
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
)
68 unsigned int DoHashes
;
70 unsigned long DeLinkLimit
;
71 string InternalPrefix
;
73 virtual bool DoPackage(string FileName
) = 0;
74 bool RecursiveScan(string
const &Dir
);
75 bool LoadFileList(string
const &BaseDir
,string
const &File
);
76 void ClearPatterns() { Patterns
.clear(); };
77 void AddPattern(string
const &Pattern
) { Patterns
.push_back(Pattern
); };
78 void AddPattern(char const *Pattern
) { Patterns
.push_back(Pattern
); };
79 void AddPatterns(std::vector
<std::string
> const &patterns
) { Patterns
.insert(Patterns
.end(), patterns
.begin(), patterns
.end()); };
80 bool SetExts(string
const &Vals
);
82 FTWScanner(FileFd
* const Output
, string
const &Arch
= string());
83 virtual ~FTWScanner();
88 class TranslationWriter
91 std::set
<string
> Included
;
95 bool DoPackage(string
const &Pkg
, string
const &Desc
, string
const &MD5
);
97 TranslationWriter(string
const &File
, string
const &TransCompress
, mode_t
const &Permissions
);
101 class PackagesWriter
: public FTWScanner
112 bool LongDescription
;
117 struct CacheDB::Stats
&Stats
;
118 TranslationWriter
* const TransWriter
;
120 inline bool ReadOverride(string
const &File
) {return Over
.ReadOverride(File
);};
121 inline bool ReadExtraOverride(string
const &File
)
122 {return Over
.ReadExtraOverride(File
);};
123 virtual bool DoPackage(string FileName
) APT_OVERRIDE
;
125 PackagesWriter(FileFd
* const Output
, TranslationWriter
* const TransWriter
, string
const &DB
,
126 string
const &Overrides
,
127 string
const &ExtOverrides
= "",
128 string
const &Arch
= "");
129 virtual ~PackagesWriter();
132 class ContentsWriter
: public FTWScanner
141 struct CacheDB::Stats
&Stats
;
144 bool DoPackage(string FileName
,string Package
);
145 virtual bool DoPackage(string FileName
) APT_OVERRIDE
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(FileFd
* const Output
, string
const &DB
, string
const &Arch
= string());
153 virtual ~ContentsWriter() {};
156 class SourcesWriter
: public FTWScanner
162 unsigned long long BufSize
;
172 struct CacheDB::Stats
&Stats
;
174 virtual bool DoPackage(string FileName
) APT_OVERRIDE
;
176 SourcesWriter(FileFd
* const Output
, string
const &DB
,string
const &BOverrides
,string
const &SOverrides
,
177 string
const &ExtOverrides
=string());
178 virtual ~SourcesWriter() {free(Buffer
);};
181 class ReleaseWriter
: public FTWScanner
184 ReleaseWriter(FileFd
* const Output
, string
const &DB
);
185 virtual bool DoPackage(string FileName
) APT_OVERRIDE
;
194 HashStringList Hashes
;
195 // Limited by FileFd::Size()
196 unsigned long long size
;
200 map
<string
,struct CheckSum
> CheckSums
;