summaryrefslogtreecommitdiff
path: root/apt-pkg/contrib/fileutl.h
diff options
context:
space:
mode:
authorDavid Kalnischkies <kalnischkies@gmail.com>2011-12-10 19:31:36 +0100
committerDavid Kalnischkies <kalnischkies@gmail.com>2011-12-10 19:31:36 +0100
commit468720c59fcf48b20332cdb7b601b2b0d7cbbfbb (patch)
treef01d2dcf5827a86706567387c1a0af50c4cf21dd /apt-pkg/contrib/fileutl.h
parent8e16d8c39447809506a8cd8e6f88cae3c168f82d (diff)
enable FileFd to guess the compressor based on the filename if requested or
to search for compressed silbings of the given filename and use this guessing instead of hardcoding Gzip compression
Diffstat (limited to 'apt-pkg/contrib/fileutl.h')
-rw-r--r--apt-pkg/contrib/fileutl.h14
1 files changed, 11 insertions, 3 deletions
diff --git a/apt-pkg/contrib/fileutl.h b/apt-pkg/contrib/fileutl.h
index fa8f92272..59a9d97e3 100644
--- a/apt-pkg/contrib/fileutl.h
+++ b/apt-pkg/contrib/fileutl.h
@@ -61,7 +61,7 @@ class FileFd
ReadOnlyGzip,
WriteAtomic = ReadWrite | Create | Atomic
};
- enum CompressMode { Auto, None, Gzip, Bzip2, Lzma, Xz };
+ enum CompressMode { Auto = 'A', None = 'N', Extension = 'E', Gzip = 'G', Bzip2 = 'B', Lzma = 'L', Xz = 'X' };
inline bool Read(void *To,unsigned long long Size,bool AllowEof)
{
@@ -94,7 +94,7 @@ class FileFd
}
bool Open(std::string FileName,OpenMode Mode,CompressMode Compress,unsigned long Perms = 0666);
- inline bool Open(std::string const &FileName,OpenMode Mode,unsigned long Perms = 0666) {
+ inline bool Open(std::string const &FileName,OpenMode Mode, unsigned long Perms = 0666) {
return Open(FileName, Mode, None, Perms);
};
bool OpenDescriptor(int Fd, OpenMode Mode, CompressMode Compress, bool AutoClose=false);
@@ -118,11 +118,19 @@ class FileFd
FileFd(std::string FileName,OpenMode Mode,unsigned long Perms = 0666) : iFd(-1),
Flags(0), gz(NULL)
{
- Open(FileName,Mode,Perms);
+ Open(FileName,Mode, None, Perms);
+ };
+ FileFd(std::string FileName,OpenMode Mode, CompressMode Compress, unsigned long Perms = 0666) :
+ iFd(-1), Flags(0), gz(NULL)
+ {
+ Open(FileName,Mode, Compress, Perms);
};
FileFd(int Fd = -1) : iFd(Fd), Flags(AutoClose), gz(NULL) {};
FileFd(int Fd,bool) : iFd(Fd), Flags(0), gz(NULL) {};
virtual ~FileFd();
+
+ private:
+ bool OpenInternDescriptor(OpenMode Mode, CompressMode Compress);
};
bool RunScripts(const char *Cnf);