mirror of
https://github.com/RPCSX/llvm.git
synced 2024-11-24 04:09:45 +00:00
Add lastAccessedTime to file_status
Reviewers: silvas Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D18456 From: Mehdi Amini <mehdi.amini@apple.com> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264387 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
256567583d
commit
b474b03196
@ -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),
|
||||
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)
|
||||
: 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) : 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;
|
||||
|
||||
|
@ -174,6 +174,12 @@ std::string getMainExecutable(const char *argv0, void *MainAddr) {
|
||||
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 StatRet, const struct stat &Status,
|
||||
|
||||
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();
|
||||
}
|
||||
|
@ -151,6 +151,16 @@ UniqueID file_status::getUniqueID() const {
|
||||
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 FileHandle, file_status &Result) {
|
||||
? 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);
|
||||
|
Loading…
Reference in New Issue
Block a user