X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/dc738e7ae6a9c14992279dc2c52f71b14ced53aa..ff6bf1be3844bcda15303efc81e234ede7501e3c:/methods/gzip.cc diff --git a/methods/gzip.cc b/methods/gzip.cc index 35501cb0a..f732c0b86 100644 --- a/methods/gzip.cc +++ b/methods/gzip.cc @@ -1,6 +1,6 @@ // -*- 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 @@ -9,7 +9,6 @@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ -#include #include #include #include @@ -21,6 +20,7 @@ #include #include #include +#include /*}}}*/ const char *Prog; @@ -52,12 +52,19 @@ bool GzipMethod::Fetch(FetchItem *Itm) // 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]); @@ -111,6 +118,7 @@ bool GzipMethod::Fetch(FetchItem *Itm) if (To.Write(Buffer,Count) == false) { Failed = true; + FromGz.Close(); break; } } @@ -154,6 +162,8 @@ bool GzipMethod::Fetch(FetchItem *Itm) int main(int argc, char *argv[]) { + setlocale(LC_ALL, ""); + GzipMethod Mth; Prog = strrchr(argv[0],'/');