Changeset View
Changeset View
Standalone View
Standalone View
lib/Support/Windows/Path.inc
Show First 20 Lines • Show All 145 Lines • ▼ Show 20 Lines | UniqueID file_status::getUniqueID() const { | ||||
// The file is uniquely identified by the volume serial number along | // The file is uniquely identified by the volume serial number along | ||||
// with the 64-bit file identifier. | // with the 64-bit file identifier. | ||||
uint64_t FileID = (static_cast<uint64_t>(FileIndexHigh) << 32ULL) | | uint64_t FileID = (static_cast<uint64_t>(FileIndexHigh) << 32ULL) | | ||||
static_cast<uint64_t>(FileIndexLow); | static_cast<uint64_t>(FileIndexLow); | ||||
return UniqueID(VolumeSerialNumber, FileID); | 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 { | TimeValue file_status::getLastModificationTime() const { | ||||
ULARGE_INTEGER UI; | ULARGE_INTEGER UI; | ||||
UI.LowPart = LastWriteTimeLow; | UI.LowPart = LastWriteTimeLow; | ||||
UI.HighPart = LastWriteTimeHigh; | UI.HighPart = LastWriteTimeHigh; | ||||
TimeValue Ret; | TimeValue Ret; | ||||
Ret.fromWin32Time(UI.QuadPart); | Ret.fromWin32Time(UI.QuadPart); | ||||
return Ret; | return Ret; | ||||
▲ Show 20 Lines • Show All 160 Lines • ▼ Show 20 Lines | |||||
bool can_execute(const Twine &Path) { | bool can_execute(const Twine &Path) { | ||||
return !access(Path, AccessMode::Execute) || | return !access(Path, AccessMode::Execute) || | ||||
!access(Path + ".exe", AccessMode::Execute); | !access(Path + ".exe", AccessMode::Execute); | ||||
} | } | ||||
bool equivalent(file_status A, file_status B) { | bool equivalent(file_status A, file_status B) { | ||||
assert(status_known(A) && status_known(B)); | assert(status_known(A) && status_known(B)); | ||||
return A.FileIndexHigh == B.FileIndexHigh && | return A.FileIndexHigh == B.FileIndexHigh && | ||||
A.FileIndexLow == B.FileIndexLow && | A.FileIndexLow == B.FileIndexLow && | ||||
A.FileSizeHigh == B.FileSizeHigh && | A.FileSizeHigh == B.FileSizeHigh && | ||||
A.FileSizeLow == B.FileSizeLow && | A.FileSizeLow == B.FileSizeLow && | ||||
A.LastAccessedTimeHigh == B.LastAccessedTimeHigh && | |||||
A.LastAccessedTimeLow == B.LastAccessedTimeLow && | |||||
A.LastWriteTimeHigh == B.LastWriteTimeHigh && | A.LastWriteTimeHigh == B.LastWriteTimeHigh && | ||||
A.LastWriteTimeLow == B.LastWriteTimeLow && | A.LastWriteTimeLow == B.LastWriteTimeLow && | ||||
A.VolumeSerialNumber == B.VolumeSerialNumber; | A.VolumeSerialNumber == B.VolumeSerialNumber; | ||||
} | } | ||||
std::error_code equivalent(const Twine &A, const Twine &B, bool &result) { | std::error_code equivalent(const Twine &A, const Twine &B, bool &result) { | ||||
file_status fsA, fsB; | file_status fsA, fsB; | ||||
if (std::error_code ec = status(A, fsA)) | if (std::error_code ec = status(A, fsA)) | ||||
return ec; | return ec; | ||||
if (std::error_code ec = status(B, fsB)) | if (std::error_code ec = status(B, fsB)) | ||||
return ec; | return ec; | ||||
▲ Show 20 Lines • Show All 54 Lines • ▼ Show 20 Lines | static std::error_code getStatus(HANDLE FileHandle, file_status &Result) { | ||||
if (!::GetFileInformationByHandle(FileHandle, &Info)) | if (!::GetFileInformationByHandle(FileHandle, &Info)) | ||||
goto handle_status_error; | goto handle_status_error; | ||||
{ | { | ||||
file_type Type = (Info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) | file_type Type = (Info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) | ||||
? file_type::directory_file | ? file_type::directory_file | ||||
: file_type::regular_file; | : file_type::regular_file; | ||||
Result = | Result = | ||||
file_status(Type, Info.ftLastWriteTime.dwHighDateTime, | file_status(Type, Info.lpLastAccessTime.dwHighDateTime, | ||||
Info.lpLastAccessTime.dwLowDateTime, | |||||
Info.ftLastWriteTime.dwHighDateTime, | |||||
Info.ftLastWriteTime.dwLowDateTime, | Info.ftLastWriteTime.dwLowDateTime, | ||||
Info.dwVolumeSerialNumber, Info.nFileSizeHigh, | Info.dwVolumeSerialNumber, Info.nFileSizeHigh, | ||||
Info.nFileSizeLow, Info.nFileIndexHigh, Info.nFileIndexLow); | Info.nFileSizeLow, Info.nFileIndexHigh, Info.nFileIndexLow); | ||||
return std::error_code(); | return std::error_code(); | ||||
} | } | ||||
handle_status_error: | handle_status_error: | ||||
DWORD LastError = ::GetLastError(); | DWORD LastError = ::GetLastError(); | ||||
▲ Show 20 Lines • Show All 476 Lines • Show Last 20 Lines |