From 8e06abb2587d06891a84414f09f4910429451bf8 Mon Sep 17 00:00:00 2001 From: Arch Librarian Date: Mon, 20 Sep 2004 16:50:52 +0000 Subject: Class File name change to FileFd Author: jgg Date: 1998-07-19 04:42:10 GMT Class File name change to FileFd --- apt-pkg/contrib/fileutl.cc | 37 +++++++++++++++++++++---------------- apt-pkg/contrib/fileutl.h | 16 ++++++++-------- apt-pkg/contrib/mmap.cc | 6 +++--- apt-pkg/contrib/mmap.h | 8 ++++---- apt-pkg/deb/deblistparser.cc | 4 ++-- apt-pkg/deb/deblistparser.h | 4 ++-- apt-pkg/tagfile.cc | 4 ++-- apt-pkg/tagfile.h | 6 +++--- cmdline/apt-cache.cc | 10 +++++----- 9 files changed, 50 insertions(+), 45 deletions(-) diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc index 6f515fd67..b29b2e098 100644 --- a/apt-pkg/contrib/fileutl.cc +++ b/apt-pkg/contrib/fileutl.cc @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: fileutl.cc,v 1.5 1998/07/15 05:56:43 jgg Exp $ +// $Id: fileutl.cc,v 1.6 1998/07/19 04:42:12 jgg Exp $ /* ###################################################################### File Utilities @@ -29,7 +29,7 @@ // CopyFile - Buffered copy of a file /*{{{*/ // --------------------------------------------------------------------- /* The caller is expected to set things so that failure causes erasure */ -bool CopyFile(File From,File To) +bool CopyFile(FileFd From,FileFd To) { if (From.IsOpen() == false || To.IsOpen() == false) return false; @@ -108,10 +108,10 @@ string SafeGetCWD() } /*}}}*/ -// File::File - Open a file /*{{{*/ +// FileFd::FileFd - Open a file /*{{{*/ // --------------------------------------------------------------------- /* The most commonly used open mode combinations are given with Mode */ -File::File(string FileName,OpenMode Mode, unsigned long Perms) +FileFd::FileFd(string FileName,OpenMode Mode, unsigned long Perms) { Flags = AutoClose; switch (Mode) @@ -128,6 +128,11 @@ File::File(string FileName,OpenMode Mode, unsigned long Perms) case WriteExists: iFd = open(FileName.c_str(),O_RDWR); break; + + // Dont use this in public directories + case LockEmpty: + iFd = open(FileName.c_str(),O_RDWR | O_CREAT | O_TRUNC,Perms); + break; } if (iFd < 0) @@ -136,19 +141,19 @@ File::File(string FileName,OpenMode Mode, unsigned long Perms) this->FileName = FileName; } /*}}}*/ -// File::~File - Closes the file /*{{{*/ +// FileFd::~File - Closes the file /*{{{*/ // --------------------------------------------------------------------- /* If the proper modes are selected then we close the Fd and possibly unlink the file on error. */ -File::~File() +FileFd::~FileFd() { Close(); } /*}}}*/ -// File::Read - Read a bit of the file /*{{{*/ +// FileFd::Read - Read a bit of the file /*{{{*/ // --------------------------------------------------------------------- /* */ -bool File::Read(void *To,unsigned long Size) +bool FileFd::Read(void *To,unsigned long Size) { if (read(iFd,To,Size) != (signed)Size) { @@ -159,10 +164,10 @@ bool File::Read(void *To,unsigned long Size) return true; } /*}}}*/ -// File::Write - Write to the file /*{{{*/ +// FileFd::Write - Write to the file /*{{{*/ // --------------------------------------------------------------------- /* */ -bool File::Write(void *From,unsigned long Size) +bool FileFd::Write(void *From,unsigned long Size) { if (write(iFd,From,Size) != (signed)Size) { @@ -173,10 +178,10 @@ bool File::Write(void *From,unsigned long Size) return true; } /*}}}*/ -// File::Seek - Seek in the file /*{{{*/ +// FileFd::Seek - Seek in the file /*{{{*/ // --------------------------------------------------------------------- /* */ -bool File::Seek(unsigned long To) +bool FileFd::Seek(unsigned long To) { if (lseek(iFd,To,SEEK_SET) != (signed)To) { @@ -187,10 +192,10 @@ bool File::Seek(unsigned long To) return true; } /*}}}*/ -// File::Size - Return the size of the file /*{{{*/ +// FileFd::Size - Return the size of the file /*{{{*/ // --------------------------------------------------------------------- /* */ -unsigned long File::Size() +unsigned long FileFd::Size() { struct stat Buf; if (fstat(iFd,&Buf) != 0) @@ -198,10 +203,10 @@ unsigned long File::Size() return Buf.st_size; } /*}}}*/ -// File::Close - Close the file if the close flag is set /*{{{*/ +// FileFd::Close - Close the file if the close flag is set /*{{{*/ // --------------------------------------------------------------------- /* */ -bool File::Close() +bool FileFd::Close() { bool Res = true; if ((Flags & AutoClose) == AutoClose) diff --git a/apt-pkg/contrib/fileutl.h b/apt-pkg/contrib/fileutl.h index 3328ce2b4..b53b499ab 100644 --- a/apt-pkg/contrib/fileutl.h +++ b/apt-pkg/contrib/fileutl.h @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: fileutl.h,v 1.3 1998/07/12 23:58:49 jgg Exp $ +// $Id: fileutl.h,v 1.4 1998/07/19 04:42:13 jgg Exp $ /* ###################################################################### File Utilities @@ -28,7 +28,7 @@ #include -class File +class FileFd { protected: int iFd; @@ -38,7 +38,7 @@ class File string FileName; public: - enum OpenMode {ReadOnly,WriteEmpty,WriteExists}; + enum OpenMode {ReadOnly,WriteEmpty,WriteExists,LockEmpty}; bool Read(void *To,unsigned long Size); bool Write(void *From,unsigned long Size); @@ -53,13 +53,13 @@ class File inline void EraseOnFailure() {Flags |= DelOnFail;}; inline void OpFail() {Flags |= Fail;}; - File(string FileName,OpenMode Mode,unsigned long Perms = 0666); - File(int Fd) : iFd(Fd), Flags(AutoClose) {}; - File(int Fd,bool) : iFd(Fd), Flags(0) {}; - virtual ~File(); + FileFd(string FileName,OpenMode Mode,unsigned long Perms = 0666); + FileFd(int Fd) : iFd(Fd), Flags(AutoClose) {}; + FileFd(int Fd,bool) : iFd(Fd), Flags(0) {}; + virtual ~FileFd(); }; -bool CopyFile(string From,string To); +bool CopyFile(FileFd From,FileFd To); int GetLock(string File,bool Errors = true); bool FileExists(string File); string SafeGetCWD(); diff --git a/apt-pkg/contrib/mmap.cc b/apt-pkg/contrib/mmap.cc index 22251c95a..f8582a1ef 100644 --- a/apt-pkg/contrib/mmap.cc +++ b/apt-pkg/contrib/mmap.cc @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: mmap.cc,v 1.6 1998/07/15 05:56:44 jgg Exp $ +// $Id: mmap.cc,v 1.7 1998/07/19 04:42:14 jgg Exp $ /* ###################################################################### MMap Class - Provides 'real' mmap or a faked mmap using read(). @@ -39,7 +39,7 @@ // MMap::MMap - Constructor /*{{{*/ // --------------------------------------------------------------------- /* */ -MMap::MMap(File &F,unsigned long Flags) : Fd(F), Flags(Flags), iSize(0), +MMap::MMap(FileFd &F,unsigned long Flags) : Fd(F), Flags(Flags), iSize(0), Base(0) { if ((Flags & NoImmMap) != NoImmMap) @@ -124,7 +124,7 @@ bool MMap::Sync(unsigned long Start,unsigned long Stop) // DynamicMMap::DynamicMMap - Constructor /*{{{*/ // --------------------------------------------------------------------- /* */ -DynamicMMap::DynamicMMap(File &F,unsigned long Flags,unsigned long WorkSpace) : +DynamicMMap::DynamicMMap(FileFd &F,unsigned long Flags,unsigned long WorkSpace) : MMap(F,Flags | NoImmMap), WorkSpace(WorkSpace) { unsigned long EndOfFile = Fd.Size(); diff --git a/apt-pkg/contrib/mmap.h b/apt-pkg/contrib/mmap.h index b935ac411..512b8bcf6 100644 --- a/apt-pkg/contrib/mmap.h +++ b/apt-pkg/contrib/mmap.h @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: mmap.h,v 1.5 1998/07/15 05:56:45 jgg Exp $ +// $Id: mmap.h,v 1.6 1998/07/19 04:42:15 jgg Exp $ /* ###################################################################### MMap Class - Provides 'real' mmap or a faked mmap using read(). @@ -37,7 +37,7 @@ class MMap { protected: - File &Fd; + FileFd &Fd; unsigned long Flags; unsigned long iSize; void *Base; @@ -58,7 +58,7 @@ class MMap bool Sync(); bool Sync(unsigned long Start,unsigned long Stop); - MMap(File &F,unsigned long Flags); + MMap(FileFd &F,unsigned long Flags); virtual ~MMap(); }; @@ -89,7 +89,7 @@ class DynamicMMap : public MMap inline unsigned long WriteString(string S) {return WriteString(S.begin(),S.size());}; void UsePools(Pool &P,unsigned int Count) {Pools = &P; PoolCount = Count;}; - DynamicMMap(File &F,unsigned long Flags,unsigned long WorkSpace = 1024*1024); + DynamicMMap(FileFd &F,unsigned long Flags,unsigned long WorkSpace = 1024*1024); virtual ~DynamicMMap(); }; diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc index f73adabc0..c2ae6de9c 100644 --- a/apt-pkg/deb/deblistparser.cc +++ b/apt-pkg/deb/deblistparser.cc @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: deblistparser.cc,v 1.7 1998/07/16 06:08:42 jgg Exp $ +// $Id: deblistparser.cc,v 1.8 1998/07/19 04:42:16 jgg Exp $ /* ###################################################################### Package Cache Generator - Generator for the cache structure. @@ -21,7 +21,7 @@ // ListParser::debListParser - Constructor /*{{{*/ // --------------------------------------------------------------------- /* */ -debListParser::debListParser(File &File) : Tags(File) +debListParser::debListParser(FileFd &File) : Tags(File) { } /*}}}*/ diff --git a/apt-pkg/deb/deblistparser.h b/apt-pkg/deb/deblistparser.h index 63e78a988..72e8ed073 100644 --- a/apt-pkg/deb/deblistparser.h +++ b/apt-pkg/deb/deblistparser.h @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: deblistparser.h,v 1.4 1998/07/12 23:58:54 jgg Exp $ +// $Id: deblistparser.h,v 1.5 1998/07/19 04:42:17 jgg Exp $ /* ###################################################################### Debian Package List Parser - This implements the abstract parser @@ -53,7 +53,7 @@ class debListParser : public pkgCacheGenerator::ListParser virtual bool Step(); - debListParser(File &File); + debListParser(FileFd &File); }; #endif diff --git a/apt-pkg/tagfile.cc b/apt-pkg/tagfile.cc index 953f8b4a6..f6855f17a 100644 --- a/apt-pkg/tagfile.cc +++ b/apt-pkg/tagfile.cc @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: tagfile.cc,v 1.9 1998/07/19 04:22:06 jgg Exp $ +// $Id: tagfile.cc,v 1.10 1998/07/19 04:42:10 jgg Exp $ /* ###################################################################### Fast scanner for RFC-822 type header information @@ -25,7 +25,7 @@ // TagFile::pkgTagFile - Constructor /*{{{*/ // --------------------------------------------------------------------- /* */ -pkgTagFile::pkgTagFile(File &Fd,unsigned long Size) : Fd(Fd), Size(Size) +pkgTagFile::pkgTagFile(FileFd &Fd,unsigned long Size) : Fd(Fd), Size(Size) { Buffer = new char[Size]; Start = End = Buffer; diff --git a/apt-pkg/tagfile.h b/apt-pkg/tagfile.h index 8e3dba33d..912558e8f 100644 --- a/apt-pkg/tagfile.h +++ b/apt-pkg/tagfile.h @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: tagfile.h,v 1.6 1998/07/19 04:22:07 jgg Exp $ +// $Id: tagfile.h,v 1.7 1998/07/19 04:42:11 jgg Exp $ /* ###################################################################### Fast scanner for RFC-822 type header information @@ -50,7 +50,7 @@ class pkgTagSection class pkgTagFile { - File &Fd; + FileFd &Fd; char *Buffer; char *Start; char *End; @@ -66,7 +66,7 @@ class pkgTagFile inline unsigned long Offset() {return iOffset;}; bool Jump(pkgTagSection &Tag,unsigned long Offset); - pkgTagFile(File &F,unsigned long Size = 32*1024); + pkgTagFile(FileFd &F,unsigned long Size = 32*1024); }; #endif diff --git a/cmdline/apt-cache.cc b/cmdline/apt-cache.cc index e36bff198..b50211fbb 100644 --- a/cmdline/apt-cache.cc +++ b/cmdline/apt-cache.cc @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: apt-cache.cc,v 1.3 1998/07/19 04:22:10 jgg Exp $ +// $Id: apt-cache.cc,v 1.4 1998/07/19 04:42:18 jgg Exp $ /* ###################################################################### apt-cache - Manages the cache file. @@ -217,7 +217,7 @@ bool DumpAvail(pkgCache &Cache) return _error->Error("Package file %s is out of sync.",I.FileName()); } - File PkgF(I.FileName(),File::ReadOnly); + FileFd PkgF(I.FileName(),FileFd::ReadOnly); if (_error->PendingError() == true) { delete [] Buffer; @@ -260,7 +260,7 @@ bool DoAdd(int argc,char *argv[]) string Ver; // Open the cache - File CacheF(CacheFile,File::WriteEmpty); + FileFd CacheF(CacheFile,FileFd::WriteEmpty); if (_error->PendingError() == true) return false; @@ -279,7 +279,7 @@ bool DoAdd(int argc,char *argv[]) cout << FileName << endl; // Do the merge - File TagF(FileName.c_str(),File::ReadOnly); + FileFd TagF(FileName.c_str(),FileFd::ReadOnly); debListParser Parser(TagF); if (_error->PendingError() == true) return _error->Error("Problem opening %s",FileName.c_str()); @@ -317,7 +317,7 @@ int main(int argc, char *argv[]) } // Open the cache file - File CacheF(CacheFile,File::ReadOnly); + FileFd CacheF(CacheFile,FileFd::ReadOnly); if (_error->PendingError() == true) break; -- cgit v1.2.3