summaryrefslogtreecommitdiff
path: root/methods/gzip.cc
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2012-04-11 17:45:36 +0200
committerMichael Vogt <michael.vogt@ubuntu.com>2012-04-11 17:45:36 +0200
commitc3753d1de25737aed66d6ca14d0473042b7c55a7 (patch)
tree750745b523fee36d66b4cdd041fc8117be22c5fe /methods/gzip.cc
parent621aeca0bc8fe39c57d6221c7581c758e5822fd0 (diff)
parentd68d65ad637526e46ea77ab83e07470d26df15fc (diff)
merged from donkults experimental branch
Diffstat (limited to 'methods/gzip.cc')
-rw-r--r--methods/gzip.cc18
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();
}