[interchange] Add preserve_times attribute to [cp] tag.

Stefan Hornburg <[email protected]>
Newsgroups gmane.comp.web.interchange.cvs
Message-ID <[email protected]>
commit 3660fed8e00bc3fd4467d325ce9c9cc617f38ed9
Author: Stefan Hornburg (Racke) <[email protected]>
Date:   Sun Nov 14 12:54:04 2010 +0100

    Add preserve_times attribute to [cp] tag.

 code/UI_Tag/cp.coretag |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)
---
diff --git a/code/UI_Tag/cp.coretag b/code/UI_Tag/cp.coretag
index 574e0ef..2cf46b7 100644
--- a/code/UI_Tag/cp.coretag
+++ b/code/UI_Tag/cp.coretag
@@ -21,6 +21,20 @@ sub {
 		$save_mask = umask($opt->{umask});
 	}
 	my $status = File::Copy::copy($from, $to);
+
+	if ($opt->{preserve_times}) {
+		my ($atime, $mtime);
+
+		($atime, $mtime) = (stat $from)[8,9];
+
+		if ($atime) {
+			$status = utime($atime, $mtime, $from);
+		}
+		else {
+			$status = 0;
+		}
+	}
+
 	umask($save_mask) if defined $save_mask;
 	return '' if $opt->{hide};
 	return $status;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.