[llvm] r264387 - Add lastAccessedTime to file_status
Mehdi Amini via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 24 22:58:11 PDT 2016
Author: mehdi_amini
Date: Fri Mar 25 00:58:11 2016
New Revision: 264387
URL: http://llvm.org/viewvc/llvm-project?rev=264387&view=rev
Log:
Add lastAccessedTime to file_status
Reviewers: silvas
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D18456
From: Mehdi Amini <mehdi.amini at apple.com>
Modified:
llvm/trunk/include/llvm/Support/FileSystem.h
llvm/trunk/lib/Support/Unix/Path.inc
llvm/trunk/lib/Support/Windows/Path.inc
Modified: llvm/trunk/include/llvm/Support/FileSystem.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/FileSystem.h?rev=264387&r1=264386&r2=264387&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/FileSystem.h (original)
+++ llvm/trunk/include/llvm/Support/FileSystem.h Fri Mar 25 00:58:11 2016
@@ -140,11 +140,14 @@ class file_status
#if defined(LLVM_ON_UNIX)
dev_t fs_st_dev;
ino_t fs_st_ino;
+ time_t fs_st_atime;
time_t fs_st_mtime;
uid_t fs_st_uid;
gid_t fs_st_gid;
off_t fs_st_size;
#elif defined (LLVM_ON_WIN32)
+ uint32_t LastAccessedTimeHigh;
+ uint32_t LastAccessedTimeLow;
uint32_t LastWriteTimeHigh;
uint32_t LastWriteTimeLow;
uint32_t VolumeSerialNumber;
@@ -159,43 +162,50 @@ class file_status
public:
#if defined(LLVM_ON_UNIX)
- file_status() : fs_st_dev(0), fs_st_ino(0), fs_st_mtime(0),
+ file_status()
+ : fs_st_dev(0), fs_st_ino(0), fs_st_atime(0), fs_st_mtime(0),
fs_st_uid(0), fs_st_gid(0), fs_st_size(0),
Type(file_type::status_error), Perms(perms_not_known) {}
- file_status(file_type Type) : fs_st_dev(0), fs_st_ino(0), fs_st_mtime(0),
+ file_status(file_type Type)
+ : fs_st_dev(0), fs_st_ino(0), fs_st_atime(0), fs_st_mtime(0),
fs_st_uid(0), fs_st_gid(0), fs_st_size(0), Type(Type),
Perms(perms_not_known) {}
- file_status(file_type Type, perms Perms, dev_t Dev, ino_t Ino, time_t MTime,
- uid_t UID, gid_t GID, off_t Size)
- : fs_st_dev(Dev), fs_st_ino(Ino), fs_st_mtime(MTime), fs_st_uid(UID),
- fs_st_gid(GID), fs_st_size(Size), Type(Type), Perms(Perms) {}
+ file_status(file_type Type, perms Perms, dev_t Dev, ino_t Ino, time_t MTime,
+ time_t ATime, uid_t UID, gid_t GID, off_t Size)
+ : fs_st_dev(Dev), fs_st_ino(Ino), fs_st_atime(ATime), fs_st_mtime(MTime),
+ fs_st_uid(UID), fs_st_gid(GID), fs_st_size(Size), Type(Type),
+ Perms(Perms) {}
#elif defined(LLVM_ON_WIN32)
- file_status() : LastWriteTimeHigh(0), LastWriteTimeLow(0),
- VolumeSerialNumber(0), FileSizeHigh(0), FileSizeLow(0),
- FileIndexHigh(0), FileIndexLow(0), Type(file_type::status_error),
- Perms(perms_not_known) {}
+ file_status()
+ : LastAccessedTimeHigh(0), LastAccessedTimeLow(0), LastWriteTimeHigh(0),
+ LastWriteTimeLow(0), VolumeSerialNumber(0), FileSizeHigh(0),
+ FileSizeLow(0), FileIndexHigh(0), FileIndexLow(0),
+ Type(file_type::status_error), Perms(perms_not_known) {}
- file_status(file_type Type) : LastWriteTimeHigh(0), LastWriteTimeLow(0),
- VolumeSerialNumber(0), FileSizeHigh(0), FileSizeLow(0),
- FileIndexHigh(0), FileIndexLow(0), Type(Type),
+ file_status(file_type Type)
+ : LastAccessedTimeHigh(0), LastAccessedTimeLow(0), LastWriteTimeHigh(0),
+ LastWriteTimeLow(0), VolumeSerialNumber(0), FileSizeHigh(0),
+ FileSizeLow(0), FileIndexHigh(0), FileIndexLow(0), Type(Type),
Perms(perms_not_known) {}
- file_status(file_type Type, uint32_t LastWriteTimeHigh,
- uint32_t LastWriteTimeLow, uint32_t VolumeSerialNumber,
- uint32_t FileSizeHigh, uint32_t FileSizeLow,
- uint32_t FileIndexHigh, uint32_t FileIndexLow)
- : LastWriteTimeHigh(LastWriteTimeHigh),
- LastWriteTimeLow(LastWriteTimeLow),
- VolumeSerialNumber(VolumeSerialNumber), FileSizeHigh(FileSizeHigh),
- FileSizeLow(FileSizeLow), FileIndexHigh(FileIndexHigh),
- FileIndexLow(FileIndexLow), Type(Type), Perms(perms_not_known) {}
+ file_status(file_type Type, uint32_t LastWriteTimeHigh,
+ uint32_t LastWriteTimeLow, uint32_t VolumeSerialNumber,
+ uint32_t FileSizeHigh, uint32_t FileSizeLow,
+ uint32_t FileIndexHigh, uint32_t FileIndexLow)
+ : LastAccessedTimeHigh(0), LastAccessedTimeLow(0),
+ LastWriteTimeHigh(LastWriteTimeHigh),
+ LastWriteTimeLow(LastWriteTimeLow),
+ VolumeSerialNumber(VolumeSerialNumber), FileSizeHigh(FileSizeHigh),
+ FileSizeLow(FileSizeLow), FileIndexHigh(FileIndexHigh),
+ FileIndexLow(FileIndexLow), Type(Type), Perms(perms_not_known) {}
#endif
// getters
file_type type() const { return Type; }
perms permissions() const { return Perms; }
+ TimeValue getLastAccessedTime() const;
TimeValue getLastModificationTime() const;
UniqueID getUniqueID() const;
Modified: llvm/trunk/lib/Support/Unix/Path.inc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Unix/Path.inc?rev=264387&r1=264386&r2=264387&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Unix/Path.inc (original)
+++ llvm/trunk/lib/Support/Unix/Path.inc Fri Mar 25 00:58:11 2016
@@ -174,6 +174,12 @@ std::string getMainExecutable(const char
return "";
}
+TimeValue file_status::getLastAccessedTime() const {
+ TimeValue Ret;
+ Ret.fromEpochTime(fs_st_atime);
+ return Ret;
+}
+
TimeValue file_status::getLastModificationTime() const {
TimeValue Ret;
Ret.fromEpochTime(fs_st_mtime);
@@ -373,8 +379,9 @@ static std::error_code fillStatus(int St
perms Perms = static_cast<perms>(Status.st_mode);
Result =
- file_status(Type, Perms, Status.st_dev, Status.st_ino, Status.st_mtime,
- Status.st_uid, Status.st_gid, Status.st_size);
+ file_status(Type, Perms, Status.st_dev, Status.st_ino, Status.st_atime,
+ Status.st_mtime, Status.st_uid, Status.st_gid,
+ Status.st_size);
return std::error_code();
}
Modified: llvm/trunk/lib/Support/Windows/Path.inc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Windows/Path.inc?rev=264387&r1=264386&r2=264387&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Windows/Path.inc (original)
+++ llvm/trunk/lib/Support/Windows/Path.inc Fri Mar 25 00:58:11 2016
@@ -151,6 +151,16 @@ UniqueID file_status::getUniqueID() cons
return UniqueID(VolumeSerialNumber, FileID);
}
+TimeValue file_status::getLastAccessedTime() const {
+ ULARGE_INTEGER UI;
+ UI.LowPart = LastAccessedTimeLow;
+ UI.HighPart = LastAccessedTimeHigh;
+
+ TimeValue Ret;
+ Ret.fromWin32Time(UI.QuadPart);
+ return Ret;
+}
+
TimeValue file_status::getLastModificationTime() const {
ULARGE_INTEGER UI;
UI.LowPart = LastWriteTimeLow;
@@ -327,13 +337,15 @@ bool can_execute(const Twine &Path) {
bool equivalent(file_status A, file_status B) {
assert(status_known(A) && status_known(B));
- return A.FileIndexHigh == B.FileIndexHigh &&
- A.FileIndexLow == B.FileIndexLow &&
- A.FileSizeHigh == B.FileSizeHigh &&
- A.FileSizeLow == B.FileSizeLow &&
- A.LastWriteTimeHigh == B.LastWriteTimeHigh &&
- A.LastWriteTimeLow == B.LastWriteTimeLow &&
- A.VolumeSerialNumber == B.VolumeSerialNumber;
+ return A.FileIndexHigh == B.FileIndexHigh &&
+ A.FileIndexLow == B.FileIndexLow &&
+ A.FileSizeHigh == B.FileSizeHigh &&
+ A.FileSizeLow == B.FileSizeLow &&
+ A.LastAccessedTimeHigh == B.LastAccessedTimeHigh &&
+ A.LastAccessedTimeLow == B.LastAccessedTimeLow &&
+ A.LastWriteTimeHigh == B.LastWriteTimeHigh &&
+ A.LastWriteTimeLow == B.LastWriteTimeLow &&
+ A.VolumeSerialNumber == B.VolumeSerialNumber;
}
std::error_code equivalent(const Twine &A, const Twine &B, bool &result) {
@@ -404,7 +416,9 @@ static std::error_code getStatus(HANDLE
? file_type::directory_file
: file_type::regular_file;
Result =
- file_status(Type, Info.ftLastWriteTime.dwHighDateTime,
+ file_status(Type, Info.lpLastAccessTime.dwHighDateTime,
+ Info.lpLastAccessTime.dwLowDateTime,
+ Info.ftLastWriteTime.dwHighDateTime,
Info.ftLastWriteTime.dwLowDateTime,
Info.dwVolumeSerialNumber, Info.nFileSizeHigh,
Info.nFileSizeLow, Info.nFileIndexHigh, Info.nFileIndexLow);
More information about the llvm-commits
mailing list