// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: gzip.cc,v 1.3 1998/10/30 07:53:53 jgg Exp $
+// $Id: gzip.cc,v 1.8 1999/07/30 05:37:00 jgg Exp $
/* ######################################################################
GZip method - Take a file URI in and decompress it into the target
#include <apt-pkg/fileutl.h>
#include <apt-pkg/error.h>
#include <apt-pkg/acquire-method.h>
-#include <strutl.h>
+#include <apt-pkg/strutl.h>
#include <sys/stat.h>
#include <unistd.h>
class GzipMethod : public pkgAcqMethod
{
- virtual bool Fetch(string Message,URI Get);
+ virtual bool Fetch(FetchItem *Itm);
public:
// GzipMethod::Fetch - Decompress the passed URI /*{{{*/
// ---------------------------------------------------------------------
/* */
-bool GzipMethod::Fetch(string Message,URI Get)
+bool GzipMethod::Fetch(FetchItem *Itm)
{
+ URI Get = Itm->Uri;
+
+ FetchResult Res;
+ Res.Filename = Itm->DestFile;
+ URIStart(Res);
+
// Open the source and destintation files
FileFd From(Get.Path,FileFd::ReadOnly);
- FileFd To(DestFile,FileFd::WriteEmpty);
+ FileFd To(Itm->DestFile,FileFd::WriteEmpty);
To.EraseOnFailure();
if (_error->PendingError() == true)
return false;
struct utimbuf TimeBuf;
TimeBuf.actime = Buf.st_atime;
TimeBuf.modtime = Buf.st_mtime;
- if (utime(DestFile.c_str(),&TimeBuf) != 0)
+ if (utime(Itm->DestFile.c_str(),&TimeBuf) != 0)
return _error->Errno("utime","Failed to set modification time");
+ if (stat(Itm->DestFile.c_str(),&Buf) != 0)
+ return _error->Errno("stat","Failed to stat");
+
// Return a Done response
- FetchResult Res;
Res.LastModified = Buf.st_mtime;
- Res.Filename = DestFile;
+ Res.Size = Buf.st_size;
URIDone(Res);
return true;