summaryrefslogtreecommitdiff
path: root/methods/copy.cc
diff options
context:
space:
mode:
authorArch Librarian <arch@canonical.com>2004-09-20 16:51:12 +0000
committerArch Librarian <arch@canonical.com>2004-09-20 16:51:12 +0000
commit92173b19af439ac49d842902a3a57105d396d7d8 (patch)
tree077dbb46b521d5f21e577f55f457a5e6b2c25897 /methods/copy.cc
parent561ab0db89ae9c4de1b37bac12d5ad8353848862 (diff)
gzip method
Author: jgg Date: 1998-10-25 07:07:29 GMT gzip method
Diffstat (limited to 'methods/copy.cc')
-rw-r--r--methods/copy.cc26
1 files changed, 24 insertions, 2 deletions
diff --git a/methods/copy.cc b/methods/copy.cc
index 68253a64c..c1cc26a69 100644
--- a/methods/copy.cc
+++ b/methods/copy.cc
@@ -1,10 +1,10 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: copy.cc,v 1.1 1998/10/25 01:57:07 jgg Exp $
+// $Id: copy.cc,v 1.2 1998/10/25 07:07:29 jgg Exp $
/* ######################################################################
Copy URI - This method takes a uri like a file: uri and copies it
- to the destination URI.
+ to the destination file.
##################################################################### */
/*}}}*/
@@ -14,6 +14,7 @@
#include <apt-pkg/error.h>
#include <sys/stat.h>
+#include <utime.h>
#include <unistd.h>
#include <stdio.h>
/*}}}*/
@@ -103,7 +104,28 @@ int main()
Fail(URI);
continue;
}
+
+ From.Close();
+ To.Close();
+ // Transfer the modification times
+ struct stat Buf;
+ if (stat(File.c_str(),&Buf) != 0)
+ {
+ _error->Errno("stat","Failed to stat");
+ Fail(URI);
+ continue;
+ }
+ struct utimbuf TimeBuf;
+ TimeBuf.actime = Buf.st_atime;
+ TimeBuf.modtime = Buf.st_mtime;
+ if (utime(Target.c_str(),&TimeBuf) != 0)
+ {
+ _error->Errno("utime","Failed to set modification time");
+ Fail(URI);
+ continue;
+ }
+
// Send the message
Result += "\n\n";
if (write(STDOUT_FILENO,Result.begin(),Result.length()) !=