diff options
author | Jim Meyering <jim@meyering.net> | 2003-08-09 17:46:13 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2003-08-09 17:46:13 +0000 |
commit | 40802a2fbd0ebbce24835ac8df116a1fc2a5db42 (patch) | |
tree | 281a502c0347109ee2ece2be9d52853fc501a798 /src | |
parent | c78cec09512b2d2114cb06d60a486124c05f6227 (diff) | |
download | coreutils-40802a2fbd0ebbce24835ac8df116a1fc2a5db42.tar.xz |
Include utimens.h.
(re_protect): Set file timestamps with utimens, not utime.
Diffstat (limited to 'src')
-rw-r--r-- | src/cp.c | 15 |
1 files changed, 7 insertions, 8 deletions
@@ -32,6 +32,7 @@ #include "dirname.h" #include "path-concat.h" #include "quote.h" +#include "utimens.h" #define ASSIGN_BASENAME_STRDUPA(Dest, File_name) \ do \ @@ -307,16 +308,14 @@ re_protect (const char *const_dst_path, int src_offset, if (x->preserve_timestamps) { - struct utimbuf utb; + struct timespec timespec[2]; - /* There's currently no interface to set file timestamps with - better than 1-second resolution, so discard any fractional - part of the source timestamp. */ + timespec[0].tv_sec = src_sb.st_atime; + timespec[0].tv_nsec = TIMESPEC_NS (src_sb.st_atim); + timespec[1].tv_sec = src_sb.st_mtime; + timespec[1].tv_nsec = TIMESPEC_NS (src_sb.st_mtim); - utb.actime = src_sb.st_atime; - utb.modtime = src_sb.st_mtime; - - if (utime (dst_path, &utb)) + if (utimens (dst_path, timespec)) { error (0, errno, _("failed to preserve times for %s"), quote (dst_path)); |