|
@@ -1,6 +1,6 @@
|
|
|
// -*- mode: cpp; mode: fold -*-
|
|
// -*- mode: cpp; mode: fold -*-
|
|
|
// Description /*{{{*/
|
|
// Description /*{{{*/
|
|
|
-// $Id: copy.cc,v 1.5 1998/11/01 05:27:40 jgg Exp $
|
|
|
|
|
|
|
+// $Id: copy.cc,v 1.6 1999/01/20 04:36:43 jgg Exp $
|
|
|
/* ######################################################################
|
|
/* ######################################################################
|
|
|
|
|
|
|
|
Copy URI - This method takes a uri like a file: uri and copies it
|
|
Copy URI - This method takes a uri like a file: uri and copies it
|
|
@@ -35,28 +35,40 @@ bool CopyMethod::Fetch(FetchItem *Itm)
|
|
|
URI Get = Itm->Uri;
|
|
URI Get = Itm->Uri;
|
|
|
string File = Get.Path;
|
|
string File = Get.Path;
|
|
|
|
|
|
|
|
|
|
+ // Stat the file and send a start message
|
|
|
|
|
+ struct stat Buf;
|
|
|
|
|
+ if (stat(File.c_str(),&Buf) != 0)
|
|
|
|
|
+ return _error->Errno("stat","Failed to stat");
|
|
|
|
|
+
|
|
|
|
|
+ // Forumulate a result and send a start message
|
|
|
|
|
+ FetchResult Res;
|
|
|
|
|
+ Res.Size = Buf.st_size;
|
|
|
|
|
+ Res.Filename = Itm->DestFile;
|
|
|
|
|
+ Res.LastModified = Buf.st_mtime;
|
|
|
|
|
+ Res.IMSHit = false;
|
|
|
|
|
+ URIStart(Res);
|
|
|
|
|
+
|
|
|
// See if the file exists
|
|
// See if the file exists
|
|
|
FileFd From(File,FileFd::ReadOnly);
|
|
FileFd From(File,FileFd::ReadOnly);
|
|
|
FileFd To(Itm->DestFile,FileFd::WriteEmpty);
|
|
FileFd To(Itm->DestFile,FileFd::WriteEmpty);
|
|
|
To.EraseOnFailure();
|
|
To.EraseOnFailure();
|
|
|
if (_error->PendingError() == true)
|
|
if (_error->PendingError() == true)
|
|
|
|
|
+ {
|
|
|
|
|
+ To.OpFail();
|
|
|
return false;
|
|
return false;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
// Copy the file
|
|
// Copy the file
|
|
|
if (CopyFile(From,To) == false)
|
|
if (CopyFile(From,To) == false)
|
|
|
|
|
+ {
|
|
|
|
|
+ To.OpFail();
|
|
|
return false;
|
|
return false;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
From.Close();
|
|
From.Close();
|
|
|
To.Close();
|
|
To.Close();
|
|
|
|
|
|
|
|
// Transfer the modification times
|
|
// Transfer the modification times
|
|
|
- struct stat Buf;
|
|
|
|
|
- if (stat(File.c_str(),&Buf) != 0)
|
|
|
|
|
- {
|
|
|
|
|
- To.OpFail();
|
|
|
|
|
- return _error->Errno("stat","Failed to stat");
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
struct utimbuf TimeBuf;
|
|
struct utimbuf TimeBuf;
|
|
|
TimeBuf.actime = Buf.st_atime;
|
|
TimeBuf.actime = Buf.st_atime;
|
|
|
TimeBuf.modtime = Buf.st_mtime;
|
|
TimeBuf.modtime = Buf.st_mtime;
|
|
@@ -66,13 +78,6 @@ bool CopyMethod::Fetch(FetchItem *Itm)
|
|
|
return _error->Errno("utime","Failed to set modification time");
|
|
return _error->Errno("utime","Failed to set modification time");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // Forumulate a result
|
|
|
|
|
- FetchResult Res;
|
|
|
|
|
- Res.Size = Buf.st_size;
|
|
|
|
|
- Res.Filename = Itm->DestFile;
|
|
|
|
|
- Res.LastModified = Buf.st_mtime;
|
|
|
|
|
- Res.IMSHit = false;
|
|
|
|
|
-
|
|
|
|
|
URIDone(Res);
|
|
URIDone(Res);
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|