summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/Unix
diff options
context:
space:
mode:
authorJordan Rupprecht <rupprecht@google.com>2018-08-13 23:03:45 +0000
committerJordan Rupprecht <rupprecht@google.com>2018-08-13 23:03:45 +0000
commit97ea485041c49fdfe0c3bac95d88753b4a461144 (patch)
tree68d61abb6737c0015297c7811ecc05a53d0cf919 /llvm/lib/Support/Unix
parent90bffb3eb98fea5730e33a8aa9a56369ffbed4c9 (diff)
downloadbcm5719-llvm-97ea485041c49fdfe0c3bac95d88753b4a461144.tar.gz
bcm5719-llvm-97ea485041c49fdfe0c3bac95d88753b4a461144.zip
[Support] NFC: Allow modifying access/modification times independently in sys::fs::setLastModificationAndAccessTime.
Summary: Add an overload to sys::fs::setLastModificationAndAccessTime that allows setting last access and modification times separately. This will allow tools to use this API when they want to preserve both the access and modification times from an input file, which may be different. Also note that both the POSIX (futimens/futimes) and Windows (SetFileTime) APIs take the two timestamps in the order of (1) access (2) modification time, so this renames the method to "setLastAccessAndModificationTime" to make it clear which timestamp is which. For existing callers, the 1-arg overload just sets both timestamps to the same thing. Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D50521 llvm-svn: 339628
Diffstat (limited to 'llvm/lib/Support/Unix')
-rw-r--r--llvm/lib/Support/Unix/Path.inc13
1 files changed, 9 insertions, 4 deletions
diff --git a/llvm/lib/Support/Unix/Path.inc b/llvm/lib/Support/Unix/Path.inc
index 7ad57d892ff..3ca006a6daf 100644
--- a/llvm/lib/Support/Unix/Path.inc
+++ b/llvm/lib/Support/Unix/Path.inc
@@ -583,17 +583,22 @@ std::error_code setPermissions(const Twine &Path, perms Permissions) {
return std::error_code();
}
-std::error_code setLastModificationAndAccessTime(int FD, TimePoint<> Time) {
+std::error_code setLastAccessAndModificationTime(int FD, TimePoint<> AccessTime,
+ TimePoint<> ModificationTime) {
#if defined(HAVE_FUTIMENS)
timespec Times[2];
- Times[0] = Times[1] = sys::toTimeSpec(Time);
+ Times[0] = sys::toTimeSpec(AccessTime);
+ Times[1] = sys::toTimeSpec(ModificationTime);
if (::futimens(FD, Times))
return std::error_code(errno, std::generic_category());
return std::error_code();
#elif defined(HAVE_FUTIMES)
timeval Times[2];
- Times[0] = Times[1] = sys::toTimeVal(
- std::chrono::time_point_cast<std::chrono::microseconds>(Time));
+ Times[0] = sys::toTimeVal(
+ std::chrono::time_point_cast<std::chrono::microseconds>(AccessTime));
+ Times[1] =
+ sys::toTimeVal(std::chrono::time_point_cast<std::chrono::microseconds>(
+ ModificationTime));
if (::futimes(FD, Times))
return std::error_code(errno, std::generic_category());
return std::error_code();
OpenPOWER on IntegriCloud