X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/421c8d109932a2615b9327c8b69aad715d4b1162..a176a0794da2ffb2025076c0ec0e9e6750a560a6:/apt-pkg/contrib/fileutl.h diff --git a/apt-pkg/contrib/fileutl.h b/apt-pkg/contrib/fileutl.h index 7ad630ce3..48bd95537 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.22 1999/09/30 06:30:34 jgg Exp $ +// $Id: fileutl.h,v 1.26 2001/05/07 05:06:52 jgg Exp $ /* ###################################################################### File Utilities @@ -21,12 +21,11 @@ #ifndef PKGLIB_FILEUTL_H #define PKGLIB_FILEUTL_H -#ifdef __GNUG__ -#pragma interface "apt-pkg/fileutl.h" -#endif #include +using std::string; + class FileFd { protected: @@ -38,9 +37,16 @@ class FileFd string FileName; public: - enum OpenMode {ReadOnly,WriteEmpty,WriteExists,WriteAny}; + enum OpenMode {ReadOnly,WriteEmpty,WriteExists,WriteAny,WriteTemp}; - bool Read(void *To,unsigned long Size,bool AllowEof = false); + inline bool Read(void *To,unsigned long Size,bool AllowEof) + { + unsigned long Jnk; + if (AllowEof) + return Read(To,Size,&Jnk); + return Read(To,Size); + } + bool Read(void *To,unsigned long Size,unsigned long *Actual = 0); bool Write(const void *From,unsigned long Size); bool Seek(unsigned long To); bool Skip(unsigned long To); @@ -49,7 +55,8 @@ class FileFd unsigned long Size(); bool Open(string FileName,OpenMode Mode,unsigned long Perms = 0666); bool Close(); - + bool Sync(); + // Simple manipulators inline int Fd() {return iFd;}; inline void Fd(int fd) {iFd = fd;}; @@ -77,12 +84,14 @@ string SafeGetCWD(); void SetCloseExec(int Fd,bool Close); void SetNonBlock(int Fd,bool Block); bool WaitFd(int Fd,bool write = false,unsigned long timeout = 0); -int ExecFork(); -bool ExecWait(int Pid,const char *Name,bool Reap = false); +pid_t ExecFork(); +bool ExecWait(pid_t Pid,const char *Name,bool Reap = false); // File string manipulators string flNotDir(string File); string flNotFile(string File); string flNoLink(string File); +string flExtension(string File); +string flCombine(string Dir,string File); #endif