summaryrefslogtreecommitdiff
path: root/ftparchive
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2010-02-18 15:07:56 +0100
committerMichael Vogt <michael.vogt@ubuntu.com>2010-02-18 15:07:56 +0100
commitb026dbb970c71213e12caaeb47bf7a27b91ea0a0 (patch)
tree68c68ff6bc12037ac74899f686fce9c0a3e419bd /ftparchive
parent07f2526e45f9978201817237745727db6177c29a (diff)
parentd328fd1a20543192a7ea3eac124f10a5793743e9 (diff)
* [BREAK] add possibility to download and use multiply
Translation files, configurable with Acquire::Translation (Closes: #444222, #448216, #550564) * Ignore :qualifiers after package name in build dependencies for now as long we don't understand them (Closes: #558103) * apt-pkg/contrib/mmap.{cc,h}: - extend it to have a growable flag - unused now but maybe... * apt-pkg/pkgcache.h: - use long instead of short for {Ver,Desc}File size, patch from Víctor Manuel Jáquez Leal, thanks! (Closes: #538917) * apt-pkg/acquire-item.cc: - allow also to skip the last patch if target is reached, thanks Bernhard R. Link! (Closes: #545699) * ftparchive/writer.{cc,h}: - add APT::FTPArchive::AlwaysStat to disable the too aggressive caching if versions are build multiply times (not recommend) Patch by Christoph Goehre, thanks! (Closes: #463260)
Diffstat (limited to 'ftparchive')
-rw-r--r--ftparchive/cachedb.cc30
-rw-r--r--ftparchive/cachedb.h22
-rw-r--r--ftparchive/contents.cc2
-rw-r--r--ftparchive/contents.h2
-rw-r--r--ftparchive/multicompress.cc14
-rw-r--r--ftparchive/multicompress.h12
-rw-r--r--ftparchive/override.cc16
-rw-r--r--ftparchive/override.h10
-rw-r--r--ftparchive/writer.cc49
-rw-r--r--ftparchive/writer.h35
10 files changed, 99 insertions, 93 deletions
diff --git a/ftparchive/cachedb.cc b/ftparchive/cachedb.cc
index e02f0e1b6..b04244347 100644
--- a/ftparchive/cachedb.cc
+++ b/ftparchive/cachedb.cc
@@ -26,7 +26,7 @@
// CacheDB::ReadyDB - Ready the DB2 /*{{{*/
// ---------------------------------------------------------------------
/* This opens the DB2 file for caching package information */
-bool CacheDB::ReadyDB(string DB)
+bool CacheDB::ReadyDB(string const &DB)
{
int err;
@@ -102,9 +102,9 @@ bool CacheDB::OpenFile()
// ---------------------------------------------------------------------
/* This gets the size from the database if it's there. If we need
* to look at the file, also get the mtime from the file. */
-bool CacheDB::GetFileStat()
+bool CacheDB::GetFileStat(bool const &doStat)
{
- if ((CurStat.Flags & FlSize) == FlSize)
+ if ((CurStat.Flags & FlSize) == FlSize && doStat == false)
{
/* Already worked out the file size */
}
@@ -160,9 +160,9 @@ bool CacheDB::GetCurStat()
/*}}}*/
// CacheDB::GetFileInfo - Get all the info about the file /*{{{*/
// ---------------------------------------------------------------------
-bool CacheDB::GetFileInfo(string FileName, bool DoControl, bool DoContents,
- bool GenContentsOnly,
- bool DoMD5, bool DoSHA1, bool DoSHA256)
+bool CacheDB::GetFileInfo(string const &FileName, bool const &DoControl, bool const &DoContents,
+ bool const &GenContentsOnly, bool const &DoMD5, bool const &DoSHA1,
+ bool const &DoSHA256, bool const &checkMtime)
{
this->FileName = FileName;
@@ -171,14 +171,18 @@ bool CacheDB::GetFileInfo(string FileName, bool DoControl, bool DoContents,
return false;
}
OldStat = CurStat;
-
- if (GetFileStat() == false)
+
+ if (GetFileStat(checkMtime) == false)
{
delete Fd;
Fd = NULL;
return false;
}
+ /* if mtime changed, update CurStat from disk */
+ if (checkMtime == true && OldStat.mtime != CurStat.mtime)
+ CurStat.Flags = FlSize;
+
Stats.Bytes += CurStat.FileSize;
Stats.Packages++;
@@ -247,7 +251,7 @@ bool CacheDB::LoadControl()
// CacheDB::LoadContents - Load the File Listing /*{{{*/
// ---------------------------------------------------------------------
/* */
-bool CacheDB::LoadContents(bool GenOnly)
+bool CacheDB::LoadContents(bool const &GenOnly)
{
// Try to read the control information out of the DB.
if ((CurStat.Flags & FlContents) == FlContents)
@@ -297,7 +301,7 @@ static string bytes2hex(uint8_t *bytes, size_t length) {
return string(space);
}
-static inline unsigned char xdig2num(char dig) {
+static inline unsigned char xdig2num(char const &dig) {
if (isdigit(dig)) return dig - '0';
if ('a' <= dig && dig <= 'f') return dig - 'a' + 10;
if ('A' <= dig && dig <= 'F') return dig - 'A' + 10;
@@ -318,7 +322,7 @@ static void hex2bytes(uint8_t *bytes, const char *hex, int length) {
// CacheDB::GetMD5 - Get the MD5 hash /*{{{*/
// ---------------------------------------------------------------------
/* */
-bool CacheDB::GetMD5(bool GenOnly)
+bool CacheDB::GetMD5(bool const &GenOnly)
{
// Try to read the control information out of the DB.
if ((CurStat.Flags & FlMD5) == FlMD5)
@@ -349,7 +353,7 @@ bool CacheDB::GetMD5(bool GenOnly)
// CacheDB::GetSHA1 - Get the SHA1 hash /*{{{*/
// ---------------------------------------------------------------------
/* */
-bool CacheDB::GetSHA1(bool GenOnly)
+bool CacheDB::GetSHA1(bool const &GenOnly)
{
// Try to read the control information out of the DB.
if ((CurStat.Flags & FlSHA1) == FlSHA1)
@@ -380,7 +384,7 @@ bool CacheDB::GetSHA1(bool GenOnly)
// CacheDB::GetSHA256 - Get the SHA256 hash /*{{{*/
// ---------------------------------------------------------------------
/* */
-bool CacheDB::GetSHA256(bool GenOnly)
+bool CacheDB::GetSHA256(bool const &GenOnly)
{
// Try to read the control information out of the DB.
if ((CurStat.Flags & FlSHA256) == FlSHA256)
diff --git a/ftparchive/cachedb.h b/ftparchive/cachedb.h
index c10f41ecc..0ba80909a 100644
--- a/ftparchive/cachedb.h
+++ b/ftparchive/cachedb.h
@@ -49,7 +49,7 @@ class CacheDB
{
return Dbp->get(Dbp,0,&Key,&Data,0) == 0;
};
- inline bool Put(const void *In,unsigned long Length)
+ inline bool Put(const void *In,unsigned long const &Length)
{
if (ReadOnly == true)
return true;
@@ -63,13 +63,13 @@ class CacheDB
return true;
}
bool OpenFile();
- bool GetFileStat();
+ bool GetFileStat(bool const &doStat = false);
bool GetCurStat();
bool LoadControl();
- bool LoadContents(bool GenOnly);
- bool GetMD5(bool GenOnly);
- bool GetSHA1(bool GenOnly);
- bool GetSHA256(bool GenOnly);
+ bool LoadContents(bool const &GenOnly);
+ bool GetMD5(bool const &GenOnly);
+ bool GetSHA1(bool const &GenOnly);
+ bool GetSHA256(bool const &GenOnly);
// Stat info stored in the DB, Fixed types since it is written to disk.
enum FlagList {FlControl = (1<<0),FlMD5=(1<<1),FlContents=(1<<2),
@@ -117,20 +117,20 @@ class CacheDB
Stats() : Bytes(0), MD5Bytes(0), SHA1Bytes(0), SHA256Bytes(0), Packages(0), Misses(0), DeLinkBytes(0) {};
} Stats;
- bool ReadyDB(string DB);
+ bool ReadyDB(string const &DB);
inline bool DBFailed() {return Dbp != 0 && DBLoaded == false;};
inline bool Loaded() {return DBLoaded == true;};
inline off_t GetFileSize(void) {return CurStat.FileSize;}
- bool SetFile(string FileName,struct stat St,FileFd *Fd);
- bool GetFileInfo(string FileName, bool DoControl, bool DoContents,
- bool GenContentsOnly, bool DoMD5, bool DoSHA1, bool DoSHA256);
+ bool SetFile(string const &FileName,struct stat St,FileFd *Fd);
+ bool GetFileInfo(string const &FileName, bool const &DoControl, bool const &DoContents, bool const &GenContentsOnly,
+ bool const &DoMD5, bool const &DoSHA1, bool const &DoSHA256, bool const &checkMtime = false);
bool Finish();
bool Clean();
- CacheDB(string DB) : Dbp(0), Fd(NULL), DebFile(0) {ReadyDB(DB);};
+ CacheDB(string const &DB) : Dbp(0), Fd(NULL), DebFile(0) {ReadyDB(DB);};
~CacheDB() {ReadyDB(string()); delete DebFile;};
};
diff --git a/ftparchive/contents.cc b/ftparchive/contents.cc
index fb1438f74..b761d9204 100644
--- a/ftparchive/contents.cc
+++ b/ftparchive/contents.cc
@@ -399,7 +399,7 @@ bool ContentsExtract::TakeContents(const void *NewData,unsigned long Length)
// ContentsExtract::Add - Read the contents data into the sorter /*{{{*/
// ---------------------------------------------------------------------
/* */
-void ContentsExtract::Add(GenContents &Contents,string Package)
+void ContentsExtract::Add(GenContents &Contents,string const &Package)
{
const char *Start = Data;
char *Pkg = Contents.Mystrdup(Package.c_str());
diff --git a/ftparchive/contents.h b/ftparchive/contents.h
index d8457cd45..5b5092b66 100644
--- a/ftparchive/contents.h
+++ b/ftparchive/contents.h
@@ -80,7 +80,7 @@ class ContentsExtract : public pkgDirStream
virtual bool DoItem(Item &Itm,int &Fd);
void Reset() {CurSize = 0;};
bool TakeContents(const void *Data,unsigned long Length);
- void Add(GenContents &Contents,string Package);
+ void Add(GenContents &Contents,string const &Package);
ContentsExtract() : Data(0), MaxSize(0), CurSize(0) {};
virtual ~ContentsExtract() {delete [] Data;};
diff --git a/ftparchive/multicompress.cc b/ftparchive/multicompress.cc
index 16cef9769..bb4beedf9 100644
--- a/ftparchive/multicompress.cc
+++ b/ftparchive/multicompress.cc
@@ -40,14 +40,14 @@ const MultiCompress::CompType MultiCompress::Compressors[] =
// MultiCompress::MultiCompress - Constructor /*{{{*/
// ---------------------------------------------------------------------
/* Setup the file outputs, compression modes and fork the writer child */
-MultiCompress::MultiCompress(string Output,string Compress,
- mode_t Permissions,bool Write)
+MultiCompress::MultiCompress(string const &Output,string const &Compress,
+ mode_t const &Permissions,bool const &Write) :
+ Permissions(Permissions)
{
Outputs = 0;
Outputter = -1;
Input = 0;
UpdateMTime = 0;
- this->Permissions = Permissions;
/* Parse the compression string, a space separated lists of compresison
types */
@@ -126,7 +126,7 @@ MultiCompress::~MultiCompress()
/* This checks each compressed file to make sure it exists and returns
stat information for a random file from the collection. False means
one or more of the files is missing. */
-bool MultiCompress::GetStat(string Output,string Compress,struct stat &St)
+bool MultiCompress::GetStat(string const &Output,string const &Compress,struct stat &St)
{
/* Parse the compression string, a space separated lists of compresison
types */
@@ -268,8 +268,8 @@ bool MultiCompress::Finalize(unsigned long &OutSize)
/* This opens the compressor, either in compress mode or decompress
mode. FileFd is always the compressor input/output file,
OutFd is the created pipe, Input for Compress, Output for Decompress. */
-bool MultiCompress::OpenCompress(const CompType *Prog,pid_t &Pid,int FileFd,
- int &OutFd,bool Comp)
+bool MultiCompress::OpenCompress(const CompType *Prog,pid_t &Pid,int const &FileFd,
+ int &OutFd,bool const &Comp)
{
Pid = -1;
@@ -369,7 +369,7 @@ bool MultiCompress::CloseOld(int Fd,pid_t Proc)
computes the MD5 of the raw data. After this the raw data in the
original files is compared to see if this data is new. If the data
is new then the temp files are renamed, otherwise they are erased. */
-bool MultiCompress::Child(int FD)
+bool MultiCompress::Child(int const &FD)
{
// Start the compression children.
for (Files *I = Outputs; I != 0; I = I->Next)
diff --git a/ftparchive/multicompress.h b/ftparchive/multicompress.h
index a65077e73..3ac3b8fb2 100644
--- a/ftparchive/multicompress.h
+++ b/ftparchive/multicompress.h
@@ -53,9 +53,9 @@ class MultiCompress
mode_t Permissions;
static const CompType Compressors[];
- bool OpenCompress(const CompType *Prog,pid_t &Pid,int FileFd,
- int &OutFd,bool Comp);
- bool Child(int Fd);
+ bool OpenCompress(const CompType *Prog,pid_t &Pid,int const &FileFd,
+ int &OutFd,bool const &Comp);
+ bool Child(int const &Fd);
bool Start();
bool Die();
@@ -68,10 +68,10 @@ class MultiCompress
bool Finalize(unsigned long &OutSize);
bool OpenOld(int &Fd,pid_t &Proc);
bool CloseOld(int Fd,pid_t Proc);
- static bool GetStat(string Output,string Compress,struct stat &St);
+ static bool GetStat(string const &Output,string const &Compress,struct stat &St);
- MultiCompress(string Output,string Compress,mode_t Permissions,
- bool Write = true);
+ MultiCompress(string const &Output,string const &Compress,
+ mode_t const &Permissions, bool const &Write = true);
~MultiCompress();
};
diff --git a/ftparchive/override.cc b/ftparchive/override.cc
index 6f40bc865..3cf10b89b 100644
--- a/ftparchive/override.cc
+++ b/ftparchive/override.cc
@@ -24,7 +24,7 @@
// Override::ReadOverride - Read the override file /*{{{*/
// ---------------------------------------------------------------------
/* This parses the override file and reads it into the map */
-bool Override::ReadOverride(string File,bool Source)
+bool Override::ReadOverride(string const &File,bool const &Source)
{
if (File.empty() == true)
return true;
@@ -132,7 +132,7 @@ bool Override::ReadOverride(string File,bool Source)
// Override::ReadExtraOverride - Read the extra override file /*{{{*/
// ---------------------------------------------------------------------
/* This parses the extra override file and reads it into the map */
-bool Override::ReadExtraOverride(string File,bool Source)
+bool Override::ReadExtraOverride(string const &File,bool const &Source)
{
if (File.empty() == true)
return true;
@@ -209,9 +209,9 @@ bool Override::ReadExtraOverride(string File,bool Source)
/* Returns a override item for the given package and the given architecture.
* Treats "all" special
*/
-Override::Item* Override::GetItem(string Package, string Architecture)
+Override::Item* Override::GetItem(string const &Package, string const &Architecture)
{
- map<string,Item>::iterator I = Mapping.find(Package);
+ map<string,Item>::const_iterator I = Mapping.find(Package);
map<string,Item>::iterator J = Mapping.find(Package + "/" + Architecture);
if (I == Mapping.end() && J == Mapping.end())
@@ -230,7 +230,7 @@ Override::Item* Override::GetItem(string Package, string Architecture)
if (R->Priority != "") result->Priority = R->Priority;
if (R->OldMaint != "") result->OldMaint = R->OldMaint;
if (R->NewMaint != "") result->NewMaint = R->NewMaint;
- for (map<string,string>::iterator foI = R->FieldOverride.begin();
+ for (map<string,string>::const_iterator foI = R->FieldOverride.begin();
foI != R->FieldOverride.end(); foI++)
{
result->FieldOverride[foI->first] = foI->second;
@@ -247,7 +247,7 @@ Override::Item* Override::GetItem(string Package, string Architecture)
there is a rule but it does not match then the empty string is returned,
also if there was no rewrite rule the empty string is returned. Failed
indicates if there was some kind of problem while rewriting. */
-string Override::Item::SwapMaint(string Orig,bool &Failed)
+string Override::Item::SwapMaint(string const &Orig,bool &Failed)
{
Failed = false;
@@ -262,10 +262,10 @@ string Override::Item::SwapMaint(string Orig,bool &Failed)
override file. Thus it persists.*/
#if 1
// Break OldMaint up into little bits on double slash boundaries.
- string::iterator End = OldMaint.begin();
+ string::const_iterator End = OldMaint.begin();
while (1)
{
- string::iterator Start = End;
+ string::const_iterator Start = End;
for (; End < OldMaint.end() &&
(End + 3 >= OldMaint.end() || End[0] != ' ' ||
End[1] != '/' || End[2] != '/'); End++);
diff --git a/ftparchive/override.h b/ftparchive/override.h
index f270556eb..c5cacc2b4 100644
--- a/ftparchive/override.h
+++ b/ftparchive/override.h
@@ -31,20 +31,20 @@ class Override
string NewMaint;
map<string,string> FieldOverride;
- string SwapMaint(string Orig,bool &Failed);
+ string SwapMaint(string const &Orig,bool &Failed);
~Item() {};
};
map<string,Item> Mapping;
- inline Item *GetItem(string Package)
+ inline Item *GetItem(string const &Package)
{
return GetItem(Package, "");
}
- Item *GetItem(string Package, string Architecture);
+ Item *GetItem(string const &Package, string const &Architecture);
- bool ReadOverride(string File,bool Source = false);
- bool ReadExtraOverride(string File,bool Source = false);
+ bool ReadOverride(string const &File,bool const &Source = false);
+ bool ReadExtraOverride(string const &File,bool const &Source = false);
};
#endif
diff --git a/ftparchive/writer.cc b/ftparchive/writer.cc
index 95b73a84d..18a3de0c2 100644
--- a/ftparchive/writer.cc
+++ b/ftparchive/writer.cc
@@ -85,7 +85,7 @@ int FTWScanner::ScannerFTW(const char *File,const struct stat *sb,int Flag)
// FTWScanner::ScannerFile - File Scanner /*{{{*/
// ---------------------------------------------------------------------
/* */
-int FTWScanner::ScannerFile(const char *File, bool ReadLink)
+int FTWScanner::ScannerFile(const char *File, bool const &ReadLink)
{
const char *LastComponent = strrchr(File, '/');
char *RealPath = NULL;
@@ -95,7 +95,7 @@ int FTWScanner::ScannerFile(const char *File, bool ReadLink)
else
LastComponent++;
- vector<string>::iterator I;
+ vector<string>::const_iterator I;
for(I = Owner->Patterns.begin(); I != Owner->Patterns.end(); ++I)
{
if (fnmatch((*I).c_str(), LastComponent, 0) == 0)
@@ -128,7 +128,7 @@ int FTWScanner::ScannerFile(const char *File, bool ReadLink)
{
Owner->NewLine(1);
- bool Type = _error->PopMessage(Err);
+ bool const Type = _error->PopMessage(Err);
if (Type == true)
cerr << _("E: ") << Err << endl;
else
@@ -149,7 +149,7 @@ int FTWScanner::ScannerFile(const char *File, bool ReadLink)
// FTWScanner::RecursiveScan - Just scan a directory tree /*{{{*/
// ---------------------------------------------------------------------
/* */
-bool FTWScanner::RecursiveScan(string Dir)
+bool FTWScanner::RecursiveScan(string const &Dir)
{
char *RealPath = NULL;
/* If noprefix is set then jam the scan root in, so we don't generate
@@ -164,7 +164,7 @@ bool FTWScanner::RecursiveScan(string Dir)
// Do recursive directory searching
Owner = this;
- int Res = ftw(Dir.c_str(),ScannerFTW,30);
+ int const Res = ftw(Dir.c_str(),ScannerFTW,30);
// Error treewalking?
if (Res != 0)
@@ -181,7 +181,7 @@ bool FTWScanner::RecursiveScan(string Dir)
// ---------------------------------------------------------------------
/* This is an alternative to using FTW to locate files, it reads the list
of files from another file. */
-bool FTWScanner::LoadFileList(string Dir,string File)
+bool FTWScanner::LoadFileList(string const &Dir, string const &File)
{
char *RealPath = NULL;
/* If noprefix is set then jam the scan root in, so we don't generate
@@ -241,7 +241,7 @@ bool FTWScanner::LoadFileList(string Dir,string File)
/* */
bool FTWScanner::Delink(string &FileName,const char *OriginalPath,
unsigned long &DeLinkBytes,
- off_t FileSize)
+ off_t const &FileSize)
{
// See if this isn't an internaly prefix'd file name.
if (InternalPrefix.empty() == false &&
@@ -298,8 +298,8 @@ bool FTWScanner::Delink(string &FileName,const char *OriginalPath,
// PackagesWriter::PackagesWriter - Constructor /*{{{*/
// ---------------------------------------------------------------------
/* */
-PackagesWriter::PackagesWriter(string DB,string Overrides,string ExtOverrides,
- string aArch) :
+PackagesWriter::PackagesWriter(string const &DB,string const &Overrides,string const &ExtOverrides,
+ string const &aArch) :
Db(DB),Stats(Db.Stats), Arch(aArch)
{
Output = stdout;
@@ -311,6 +311,7 @@ PackagesWriter::PackagesWriter(string DB,string Overrides,string ExtOverrides,
DoMD5 = _config->FindB("APT::FTPArchive::MD5",true);
DoSHA1 = _config->FindB("APT::FTPArchive::SHA1",true);
DoSHA256 = _config->FindB("APT::FTPArchive::SHA256",true);
+ DoAlwaysStat = _config->FindB("APT::FTPArchive::AlwaysStat", false);
DoContents = _config->FindB("APT::FTPArchive::Contents",true);
NoOverride = _config->FindB("APT::FTPArchive::NoOverrideMsg",false);
LongDescription = _config->FindB("APT::FTPArchive::LongDescription",true);
@@ -333,7 +334,7 @@ PackagesWriter::PackagesWriter(string DB,string Overrides,string ExtOverrides,
// FTWScanner::SetExts - Set extensions to support /*{{{*/
// ---------------------------------------------------------------------
/* */
-bool FTWScanner::SetExts(string Vals)
+bool FTWScanner::SetExts(string const &Vals)
{
ClearPatterns();
string::size_type Start = 0;
@@ -365,7 +366,7 @@ bool FTWScanner::SetExts(string Vals)
bool PackagesWriter::DoPackage(string FileName)
{
// Pull all the data we need form the DB
- if (Db.GetFileInfo(FileName, true, DoContents, true, DoMD5, DoSHA1, DoSHA256)
+ if (Db.GetFileInfo(FileName, true, DoContents, true, DoMD5, DoSHA1, DoSHA256, DoAlwaysStat)
== false)
{
return false;
@@ -480,7 +481,7 @@ bool PackagesWriter::DoPackage(string FileName)
SetTFRewriteData(Changes[End++], "Suggests", OptionalStr.c_str());
}
- for (map<string,string>::iterator I = OverItem->FieldOverride.begin();
+ for (map<string,string>::const_iterator I = OverItem->FieldOverride.begin();
I != OverItem->FieldOverride.end(); I++)
SetTFRewriteData(Changes[End++],I->first.c_str(),I->second.c_str());
@@ -498,8 +499,8 @@ bool PackagesWriter::DoPackage(string FileName)
// SourcesWriter::SourcesWriter - Constructor /*{{{*/
// ---------------------------------------------------------------------
/* */
-SourcesWriter::SourcesWriter(string BOverrides,string SOverrides,
- string ExtOverrides)
+SourcesWriter::SourcesWriter(string const &BOverrides,string const &SOverrides,
+ string const &ExtOverrides)
{
Output = stdout;
AddPattern("*.dsc");
@@ -746,7 +747,7 @@ bool SourcesWriter::DoPackage(string FileName)
if (NewMaint.empty() == false)
SetTFRewriteData(Changes[End++], "Maintainer", NewMaint.c_str());
- for (map<string,string>::iterator I = SOverItem->FieldOverride.begin();
+ for (map<string,string>::const_iterator I = SOverItem->FieldOverride.begin();
I != SOverItem->FieldOverride.end(); I++)
SetTFRewriteData(Changes[End++],I->first.c_str(),I->second.c_str());
@@ -766,7 +767,7 @@ bool SourcesWriter::DoPackage(string FileName)
// ContentsWriter::ContentsWriter - Constructor /*{{{*/
// ---------------------------------------------------------------------
/* */
-ContentsWriter::ContentsWriter(string DB) :
+ContentsWriter::ContentsWriter(string const &DB) :
Db(DB), Stats(Db.Stats)
{
@@ -778,9 +779,9 @@ ContentsWriter::ContentsWriter(string DB) :
// ---------------------------------------------------------------------
/* If Package is the empty string the control record will be parsed to
determine what the package name is. */
-bool ContentsWriter::DoPackage(string FileName,string Package)
+bool ContentsWriter::DoPackage(string FileName, string Package)
{
- if (!Db.GetFileInfo(FileName, Package.empty(), true, false, false, false, false))
+ if (!Db.GetFileInfo(FileName, Package.empty(), true, false, false, false, false, false))
{
return false;
}
@@ -799,7 +800,7 @@ bool ContentsWriter::DoPackage(string FileName,string Package)
// ContentsWriter::ReadFromPkgs - Read from a packages file /*{{{*/
// ---------------------------------------------------------------------
/* */
-bool ContentsWriter::ReadFromPkgs(string PkgFile,string PkgCompress)
+bool ContentsWriter::ReadFromPkgs(string const &PkgFile,string const &PkgCompress)
{
MultiCompress Pkgs(PkgFile,PkgCompress,0,false);
if (_error->PendingError() == true)
@@ -854,7 +855,7 @@ bool ContentsWriter::ReadFromPkgs(string PkgFile,string PkgCompress)
// ReleaseWriter::ReleaseWriter - Constructor /*{{{*/
// ---------------------------------------------------------------------
/* */
-ReleaseWriter::ReleaseWriter(string DB)
+ReleaseWriter::ReleaseWriter(string const &DB)
{
AddPattern("Packages");
AddPattern("Packages.gz");
@@ -868,7 +869,7 @@ ReleaseWriter::ReleaseWriter(string DB)
AddPattern("md5sum.txt");
Output = stdout;
- time_t now = time(NULL);
+ time_t const now = time(NULL);
char datestr[128];
if (strftime(datestr, sizeof(datestr), "%a, %d %b %Y %H:%M:%S UTC",
gmtime(&now)) == 0)
@@ -955,7 +956,7 @@ bool ReleaseWriter::DoPackage(string FileName)
void ReleaseWriter::Finish()
{
fprintf(Output, "MD5Sum:\n");
- for(map<string,struct CheckSum>::iterator I = CheckSums.begin();
+ for(map<string,struct CheckSum>::const_iterator I = CheckSums.begin();
I != CheckSums.end();
++I)
{
@@ -966,7 +967,7 @@ void ReleaseWriter::Finish()
}
fprintf(Output, "SHA1:\n");
- for(map<string,struct CheckSum>::iterator I = CheckSums.begin();
+ for(map<string,struct CheckSum>::const_iterator I = CheckSums.begin();
I != CheckSums.end();
++I)
{
@@ -977,7 +978,7 @@ void ReleaseWriter::Finish()
}
fprintf(Output, "SHA256:\n");
- for(map<string,struct CheckSum>::iterator I = CheckSums.begin();
+ for(map<string,struct CheckSum>::const_iterator I = CheckSums.begin();
I != CheckSums.end();
++I)
{
diff --git a/ftparchive/writer.h b/ftparchive/writer.h
index 9aaadbdab..520e91dd6 100644
--- a/ftparchive/writer.h
+++ b/ftparchive/writer.h
@@ -42,12 +42,12 @@ class FTWScanner
static FTWScanner *Owner;
static int ScannerFTW(const char *File,const struct stat *sb,int Flag);
- static int ScannerFile(const char *File, bool ReadLink);
+ static int ScannerFile(const char *File, bool const &ReadLink);
bool Delink(string &FileName,const char *OriginalPath,
- unsigned long &Bytes,off_t FileSize);
+ unsigned long &Bytes,off_t const &FileSize);
- inline void NewLine(unsigned Priority)
+ inline void NewLine(unsigned const &Priority)
{
if (ErrorPrinted == false && Quiet <= Priority)
{
@@ -62,11 +62,11 @@ class FTWScanner
string InternalPrefix;
virtual bool DoPackage(string FileName) = 0;
- bool RecursiveScan(string Dir);
- bool LoadFileList(string BaseDir,string File);
+ bool RecursiveScan(string const &Dir);
+ bool LoadFileList(string const &BaseDir,string const &File);
void ClearPatterns() { Patterns.clear(); };
- void AddPattern(string Pattern) { Patterns.push_back(Pattern); };
- bool SetExts(string Vals);
+ void AddPattern(string const &Pattern) { Patterns.push_back(Pattern); };
+ bool SetExts(string const &Vals);
FTWScanner();
};
@@ -82,6 +82,7 @@ class PackagesWriter : public FTWScanner
bool DoMD5;
bool DoSHA1;
bool DoSHA256;
+ bool DoAlwaysStat;
bool NoOverride;
bool DoContents;
bool LongDescription;
@@ -93,13 +94,13 @@ class PackagesWriter : public FTWScanner
struct CacheDB::Stats &Stats;
string Arch;
- inline bool ReadOverride(string File) {return Over.ReadOverride(File);};
- inline bool ReadExtraOverride(string File)
+ inline bool ReadOverride(string const &File) {return Over.ReadOverride(File);};
+ inline bool ReadExtraOverride(string const &File)
{return Over.ReadExtraOverride(File);};
virtual bool DoPackage(string FileName);
- PackagesWriter(string DB,string Overrides,string ExtOverrides=string(),
- string Arch=string());
+ PackagesWriter(string const &DB,string const &Overrides,string const &ExtOverrides=string(),
+ string const &Arch=string());
virtual ~PackagesWriter() {};
};
@@ -119,12 +120,12 @@ class ContentsWriter : public FTWScanner
bool DoPackage(string FileName,string Package);
virtual bool DoPackage(string FileName)
{return DoPackage(FileName,string());};
- bool ReadFromPkgs(string PkgFile,string PkgCompress);
+ bool ReadFromPkgs(string const &PkgFile,string const &PkgCompress);
void Finish() {Gen.Print(Output);};
- inline bool ReadyDB(string DB) {return Db.ReadyDB(DB);};
+ inline bool ReadyDB(string const &DB) {return Db.ReadyDB(DB);};
- ContentsWriter(string DB);
+ ContentsWriter(string const &DB);
virtual ~ContentsWriter() {};
};
@@ -147,15 +148,15 @@ class SourcesWriter : public FTWScanner
virtual bool DoPackage(string FileName);
- SourcesWriter(string BOverrides,string SOverrides,
- string ExtOverrides=string());
+ SourcesWriter(string const &BOverrides,string const &SOverrides,
+ string const &ExtOverrides=string());
virtual ~SourcesWriter() {free(Buffer);};
};
class ReleaseWriter : public FTWScanner
{
public:
- ReleaseWriter(string DB);
+ ReleaseWriter(string const &DB);
virtual bool DoPackage(string FileName);
void Finish();