]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/contrib/fileutl.h
Bill is consistent. Bill is correct. Be like Bill.
[apt.git] / apt-pkg / contrib / fileutl.h
index 5809bf1de8a29a33ba602bf277ccaf26f5862918..dddeb70f59c71283aefa52fd0e25a23c95abcd3e 100644 (file)
@@ -41,6 +41,13 @@ using std::string;
 class FileFdPrivate;
 class FileFd
 {
+   friend class FileFdPrivate;
+   friend class GzipFileFdPrivate;
+   friend class Bz2FileFdPrivate;
+   friend class LzmaFileFdPrivate;
+   friend class Lz4FileFdPrivate;
+   friend class DirectFileFdPrivate;
+   friend class PipedFileFdPrivate;
    protected:
    int iFd;
  
@@ -60,6 +67,7 @@ class FileFd
        Exclusive = (1 << 3),
        Atomic = Exclusive | (1 << 4),
        Empty = (1 << 5),
+       BufferedWrite = (1 << 6),
 
        WriteEmpty = ReadWrite | Create | Empty,
        WriteExists = ReadWrite,
@@ -68,7 +76,7 @@ class FileFd
        ReadOnlyGzip,
        WriteAtomic = ReadWrite | Create | Atomic
    };
-   enum CompressMode { Auto = 'A', None = 'N', Extension = 'E', Gzip = 'G', Bzip2 = 'B', Lzma = 'L', Xz = 'X' };
+   enum CompressMode { Auto = 'A', None = 'N', Extension = 'E', Gzip = 'G', Bzip2 = 'B', Lzma = 'L', Xz = 'X', Lz4='4' };
    
    inline bool Read(void *To,unsigned long long Size,bool AllowEof)
    {
@@ -78,7 +86,9 @@ class FileFd
       return Read(To,Size);
    }   
    bool Read(void *To,unsigned long long Size,unsigned long long *Actual = 0);
+   bool static Read(int const Fd, void *To, unsigned long long Size, unsigned long long * const Actual = 0);
    char* ReadLine(char *To, unsigned long long const Size);
+   bool Flush();
    bool Write(const void *From,unsigned long long Size);
    bool static Write(int Fd, const void *From, unsigned long long Size);
    bool Seek(unsigned long long To);
@@ -154,7 +164,7 @@ bool RemoveFile(char const * const Function, std::string const &FileName);
 int GetLock(std::string File,bool Errors = true);
 bool FileExists(std::string File);
 bool RealFileExists(std::string File);
-bool DirectoryExists(std::string const &Path) APT_CONST;
+bool DirectoryExists(std::string const &Path);
 bool CreateDirectory(std::string const &Parent, std::string const &Path);
 time_t GetModificationTime(std::string const &Path);
 bool Rename(std::string From, std::string To);
@@ -225,6 +235,8 @@ std::string flCombine(std::string Dir,std::string File);
 /** \brief Takes a file path and returns the absolute path
  */
 std::string flAbsPath(std::string File);
+/** \brief removes superfluous /./ and // from path */
+APT_HIDDEN std::string flNormalize(std::string file);
 
 // simple c++ glob
 std::vector<std::string> Glob(std::string const &pattern, int flags=0);
@@ -236,8 +248,11 @@ std::vector<std::string> Glob(std::string const &pattern, int flags=0);
  * \param Child a reference to the integer that stores the child pid
  *        Note that you must call ExecWait() or similar to cleanup
  * \param Mode is either FileFd::ReadOnly or FileFd::WriteOnly
+ * \param CaptureStderr True if we should capture stderr in addition to stdout.
+ *                      (default: True).
  * \return true on success, false on failure with _error set
  */
+bool Popen(const char* Args[], FileFd &Fd, pid_t &Child, FileFd::OpenMode Mode, bool CaptureStderr);
 bool Popen(const char* Args[], FileFd &Fd, pid_t &Child, FileFd::OpenMode Mode);