summaryrefslogtreecommitdiff
path: root/methods/gzip.cc
diff options
context:
space:
mode:
authorArch Librarian <arch@canonical.com>2004-09-20 16:57:15 +0000
committerArch Librarian <arch@canonical.com>2004-09-20 16:57:15 +0000
commit2204bd804ded02d3ca8f04ebc6de30204468530a (patch)
treebaf6f3d2f2d2976e59f5e0b7e83dd4779f6889f9 /methods/gzip.cc
parentdb5c1b541994e1b6d9b64a44206002b726c42dbe (diff)
Alfredos bzip2 stuff
Author: jgg Date: 2001-03-11 22:37:35 GMT Alfredos bzip2 stuff
Diffstat (limited to 'methods/gzip.cc')
-rw-r--r--methods/gzip.cc27
1 files changed, 17 insertions, 10 deletions
diff --git a/methods/gzip.cc b/methods/gzip.cc
index c0092c755..3f0efab4f 100644
--- a/methods/gzip.cc
+++ b/methods/gzip.cc
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: gzip.cc,v 1.13 2001/03/11 05:30:20 jgg Exp $
+// $Id: gzip.cc,v 1.14 2001/03/11 22:37:35 jgg Exp $
/* ######################################################################
GZip method - Take a file URI in and decompress it into the target
@@ -22,6 +22,8 @@
#include <errno.h>
/*}}}*/
+const char *Prog;
+
class GzipMethod : public pkgAcqMethod
{
virtual bool Fetch(FetchItem *Itm);
@@ -34,13 +36,14 @@ class GzipMethod : public pkgAcqMethod
// GzipMethod::Fetch - Decompress the passed URI /*{{{*/
// ---------------------------------------------------------------------
-/* This forks gzip and hashes the resulting decompressed output as it
- flows to the destination file */
+/* */
bool GzipMethod::Fetch(FetchItem *Itm)
{
URI Get = Itm->Uri;
string Path = Get.Host + Get.Path; // To account for relative paths
+ string GzPathOption = "Dir::bin::"+string(Prog);
+
FetchResult Res;
Res.Filename = Itm->DestFile;
URIStart(Res);
@@ -50,7 +53,7 @@ bool GzipMethod::Fetch(FetchItem *Itm)
int GzOut[2];
if (pipe(GzOut) < 0)
- return _error->Errno("pipe","Couldn't open pipe for gzip");
+ return _error->Errno("pipe","Couldn't open pipe for %s",Prog);
// Fork gzip
int Process = ExecFork();
@@ -65,7 +68,7 @@ bool GzipMethod::Fetch(FetchItem *Itm)
SetCloseExec(STDOUT_FILENO,false);
const char *Args[3];
- Args[0] = _config->Find("Dir::bin::gzip","gzip").c_str();
+ Args[0] = _config->Find(GzPathOption,Prog).c_str();
Args[1] = "-d";
Args[2] = 0;
execvp(Args[0],(char **)Args);
@@ -94,7 +97,7 @@ bool GzipMethod::Fetch(FetchItem *Itm)
if (Count < 0)
{
- _error->Errno("read", "Read error from gzip process");
+ _error->Errno("read", "Read error from %s process",Prog);
Failed = true;
break;
}
@@ -104,14 +107,14 @@ bool GzipMethod::Fetch(FetchItem *Itm)
Hash.Add(Buffer,Count);
if (To.Write(Buffer,Count) == false)
- {
+ {
Failed = true;
break;
- }
+ }
}
// Wait for gzip to finish
- if (ExecWait(Process,_config->Find("Dir::bin::gzip","gzip").c_str(),false) == false)
+ if (ExecWait(Process,_config->Find(GzPathOption,Prog).c_str(),false) == false)
{
To.OpFail();
return false;
@@ -147,8 +150,12 @@ bool GzipMethod::Fetch(FetchItem *Itm)
}
/*}}}*/
-int main()
+int main(int argc, char *argv[])
{
GzipMethod Mth;
+
+ Prog = strrchr(argv[0],'/');
+ Prog++;
+
return Mth.Run();
}