diff options
author | David Kalnischkies <kalnischkies@gmail.com> | 2012-04-05 18:51:06 +0200 |
---|---|---|
committer | David Kalnischkies <kalnischkies@gmail.com> | 2012-04-05 18:51:06 +0200 |
commit | d6bbcaad675a746e958d0736ead63bf44c2787ee (patch) | |
tree | 688ea3fbd6389824f9897aae85e7baafe075e36b /methods/gzip.cc | |
parent | 2024154c6d4fa1142b022d54f8c88cf8991929ff (diff) | |
download | apt-d6bbcaad675a746e958d0736ead63bf44c2787ee.tar.gz |
* methods/bzip2.cc:
- remove it as the functionality for all compressors can be
provided by gzip.cc now with the usage of FileFD
Diffstat (limited to 'methods/gzip.cc')
-rw-r--r-- | methods/gzip.cc | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/methods/gzip.cc b/methods/gzip.cc index 6ab6548ef..48c8e9892 100644 --- a/methods/gzip.cc +++ b/methods/gzip.cc @@ -25,6 +25,8 @@ #include <apti18n.h> /*}}}*/ +const char *Prog; + class GzipMethod : public pkgAcqMethod { virtual bool Fetch(FetchItem *Itm); @@ -46,9 +48,18 @@ bool GzipMethod::Fetch(FetchItem *Itm) FetchResult Res; Res.Filename = Itm->DestFile; URIStart(Res); - + + std::vector<APT::Configuration::Compressor> const compressors = APT::Configuration::getCompressors(); + std::vector<APT::Configuration::Compressor>::const_iterator compressor = compressors.begin(); + for (; compressor != compressors.end(); ++compressor) + if (compressor->Name == Prog) + break; + if (compressor == compressors.end()) + return _error->Error("Extraction of file %s requires unknown compressor %s", Path.c_str(), Prog); + // Open the source and destination files - FileFd From(Path,FileFd::ReadOnly, FileFd::Gzip); + FileFd From; + From.Open(Path, FileFd::ReadOnly, *compressor); if(From.FileSize() == 0) return _error->Error(_("Empty files can't be valid archives")); @@ -117,6 +128,9 @@ int main(int argc, char *argv[]) { setlocale(LC_ALL, ""); + Prog = strrchr(argv[0],'/'); + ++Prog; + GzipMethod Mth; return Mth.Run(); } |