summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2013-06-20 20:56:14 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2013-06-20 20:56:14 +0000
commit11ca2e508c2152732c364d02e5b381e61c851084 (patch)
treeb8cd1edf3f8767cca4cdd3460364f6e64f792666 /lib
parentdeda39dbdf2a8b07940183e5f3ed9ea89e2ae053 (diff)
downloadllvm-11ca2e508c2152732c364d02e5b381e61c851084.tar.gz
llvm-11ca2e508c2152732c364d02e5b381e61c851084.tar.bz2
llvm-11ca2e508c2152732c364d02e5b381e61c851084.tar.xz
Add a setLastModificationAndAccessTime to PathV2.
With this we can remove the last use of PathV1 from llvm-ar.cpp. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184464 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Support/Unix/PathV2.inc10
-rw-r--r--lib/Support/Windows/PathV2.inc11
2 files changed, 21 insertions, 0 deletions
diff --git a/lib/Support/Unix/PathV2.inc b/lib/Support/Unix/PathV2.inc
index 4b922da718..e9cb6e7562 100644
--- a/lib/Support/Unix/PathV2.inc
+++ b/lib/Support/Unix/PathV2.inc
@@ -441,6 +441,16 @@ error_code permissions(const Twine &path, perms prms) {
return error_code::success();
}
+error_code setLastModificationAndAccessTime(int FD, TimeValue Time) {
+ timeval Times[2];
+ Times[0].tv_sec = Time.toPosixTime();
+ Times[0].tv_usec = 0;
+ Times[1] = Times[0];
+ if (::futimes(FD, Times))
+ return error_code(errno, system_category());
+ return error_code::success();
+}
+
// Since this is most often used for temporary files, mode defaults to 0600.
error_code unique_file(const Twine &model, int &result_fd,
SmallVectorImpl<char> &result_path,
diff --git a/lib/Support/Windows/PathV2.inc b/lib/Support/Windows/PathV2.inc
index 006e31a5bd..5e0375fcf9 100644
--- a/lib/Support/Windows/PathV2.inc
+++ b/lib/Support/Windows/PathV2.inc
@@ -585,6 +585,17 @@ error_code permissions(const Twine &path, perms prms) {
return error_code::success();
}
+error_code setLastModificationAndAccessTime(int FD, TimeValue Time) {
+ ULARGE_INTEGER UI;
+ UI.QuadPart = Time.toWin32Time();
+ FILETIME FT;
+ FT.dwLowDateTime = UI.LowPart;
+ FT.dwHighDateTime = UI.HighPart;
+ HANDLE FileHandle = reinterpret_cast<HANDLE>(_get_osfhandle(FD));
+ if (!SetFileTime(FileHandle, NULL, &FT, &FT))
+ return windows_error(::GetLastError());
+ return error_code::success();
+}
// FIXME: mode should be used here and default to user r/w only,
// it currently comes in as a UNIX mode.