// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: gzip.cc,v 1.17 2003/02/10 07:34:41 doogie Exp $
+// $Id: gzip.cc,v 1.17.2.1 2004/01/16 18:58:50 mdz Exp $
/* ######################################################################
GZip method - Take a file URI in and decompress it into the target
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
-#include <apti18n.h>
#include <apt-pkg/fileutl.h>
#include <apt-pkg/error.h>
#include <apt-pkg/acquire-method.h>
#include <utime.h>
#include <stdio.h>
#include <errno.h>
+#include <apti18n.h>
/*}}}*/
const char *Prog;
// Open the source and destination files
FileFd From(Path,FileFd::ReadOnly);
+ // if the file is empty, just rename it and return
+ if(From.Size() == 0)
+ {
+ rename(Path.c_str(), Itm->DestFile.c_str());
+ return true;
+ }
+
int GzOut[2];
if (pipe(GzOut) < 0)
return _error->Errno("pipe",_("Couldn't open pipe for %s"),Prog);
// Fork gzip
- int Process = ExecFork();
+ pid_t Process = ExecFork();
if (Process == 0)
{
close(GzOut[0]);
if (To.Write(Buffer,Count) == false)
{
Failed = true;
+ FromGz.Close();
break;
}
}
int main(int argc, char *argv[])
{
+ setlocale(LC_ALL, "");
+
GzipMethod Mth;
Prog = strrchr(argv[0],'/');