From 35044438af981921afed8284bc8aea687bcba2d0 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Fri, 23 Sep 2005 20:38:34 +0000 Subject: (copy_reg): Preserve time stamps if x->preserve_timestamps is set, using futimens so that we needn't resolve the path again. (copy_internal): Don't preserve time stamps if copy_reg did it already. --- src/copy.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/copy.c b/src/copy.c index ba6ce4860..026a18d3a 100644 --- a/src/copy.c +++ b/src/copy.c @@ -403,6 +403,20 @@ copy_reg (char const *src_name, char const *dst_name, } } + if (x->preserve_timestamps) + { + struct timespec timespec[2]; + timespec[0] = get_stat_atime (src_sb); + timespec[1] = get_stat_mtime (src_sb); + + if (futimens (dest_desc, dst_name, timespec) != 0) + { + error (0, errno, _("preserving times for %s"), quote (dst_name)); + if (x->require_preserve) + return_val = false; + } + } + close_src_and_dst_desc: if (close (dest_desc) < 0) { @@ -1564,10 +1578,9 @@ copy_internal (char const *src_name, char const *dst_name, chown turns off set[ug]id bits for non-root, so do the chmod last. */ - if (x->preserve_timestamps) + if (!copied_as_regular && x->preserve_timestamps) { struct timespec timespec[2]; - timespec[0] = get_stat_atime (&src_sb); timespec[1] = get_stat_mtime (&src_sb); -- cgit v1.2.3-70-g09d2