From 699b209e5122f8fcd85fc4666c9b7020286ab0d0 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 13 Dec 2011 00:17:30 +0100 Subject: Allow the FileFd to use an external Compressor to uncompress a given file internally so that it is exported and can be used like a "normal" uncompressed file with FileFd This allows us to hide th zlib usage in the implementation and use gzip instead if we don't have zlib builtin (the same for other compressors). The code includes quiet a few FIXME's so while all tests are working it shouldn't be used just yet outside of libapt as it might break. --- apt-pkg/contrib/fileutl.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'apt-pkg/contrib/fileutl.h') diff --git a/apt-pkg/contrib/fileutl.h b/apt-pkg/contrib/fileutl.h index 209ca91e7..f96dc72dc 100644 --- a/apt-pkg/contrib/fileutl.h +++ b/apt-pkg/contrib/fileutl.h @@ -22,6 +22,7 @@ #define PKGLIB_FILEUTL_H #include +#include #include #include @@ -110,6 +111,7 @@ class FileFd inline int Fd() {return iFd;}; inline void Fd(int fd) {iFd = fd;}; __deprecated gzFile gzFd(); + inline bool IsOpen() {return iFd >= 0;}; inline bool Failed() {return (Flags & Fail) == Fail;}; inline void EraseOnFailure() {Flags |= DelOnFail;}; @@ -170,6 +172,14 @@ bool WaitFd(int Fd,bool write = false,unsigned long timeout = 0); pid_t ExecFork(); bool ExecWait(pid_t Pid,const char *Name,bool Reap = false); +bool ExecCompressor(APT::Configuration::Compressor const &Prog, + pid_t *Pid, int const FileFd, int &OutFd, bool const Comp = true); +inline bool ExecDecompressor(APT::Configuration::Compressor const &Prog, + pid_t *Pid, int const FileFd, int &OutFd) +{ + return ExecCompressor(Prog, Pid, FileFd, OutFd, true); +} + // File string manipulators std::string flNotDir(std::string File); std::string flNotFile(std::string File); -- cgit v1.2.3