diff options
author | Jeff Cohen <jeffc@jolt-lang.org> | 2004-12-14 05:26:43 +0000 |
---|---|---|
committer | Jeff Cohen <jeffc@jolt-lang.org> | 2004-12-14 05:26:43 +0000 |
commit | 2b60d39499d9ac3e5078f4a134c3fd80b46e2b94 (patch) | |
tree | 08e629779ada65207416df8c7d40ee421ef8d6e9 /llvm/lib/System/Win32/Path.cpp | |
parent | eedafda7bb5fdb6b77aab15482c9fc6c3f1a59a9 (diff) | |
download | bcm5719-llvm-2b60d39499d9ac3e5078f4a134c3fd80b46e2b94.tar.gz bcm5719-llvm-2b60d39499d9ac3e5078f4a134c3fd80b46e2b94.zip |
Implement Win32 Path::getStatusInfo(), TimeValue::toString()
llvm-svn: 18930
Diffstat (limited to 'llvm/lib/System/Win32/Path.cpp')
-rw-r--r-- | llvm/lib/System/Win32/Path.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/llvm/lib/System/Win32/Path.cpp b/llvm/lib/System/Win32/Path.cpp index 43d553bbd99..88e20cd354f 100644 --- a/llvm/lib/System/Win32/Path.cpp +++ b/llvm/lib/System/Win32/Path.cpp @@ -287,13 +287,49 @@ Path::getLast() const { return path.substr(pos+1); } +void +Path::getStatusInfo(StatusInfo& info) const { + WIN32_FILE_ATTRIBUTE_DATA fi; + if (!GetFileAttributesEx(path.c_str(), GetFileExInfoStandard, &fi)) + ThrowError(std::string(path) + ": Can't get status: "); + + info.fileSize = fi.nFileSizeHigh; + info.fileSize <<= 32; + info.fileSize += fi.nFileSizeLow; + + info.mode = 0777; // Not applicable to Windows, so... + info.user = 9999; // Not applicable to Windows, so... + info.group = 9999; // Not applicable to Windows, so... + + __int64 ft = *reinterpret_cast<__int64*>(&fi.ftLastWriteTime); + info.modTime.fromWin32Time(ft); + + info.isDir = fi.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY; + if (info.isDir && path[path.length() - 1] != '/') + path += '/'; + else if (!info.isDir && path[path.length() - 1] == '/') + path.erase(path.length() - 1); +} + void Path::makeReadable() { + // All files are readable on Windows (ignoring security attributes). } void Path::makeWriteable() { + DWORD attr = GetFileAttributes(path.c_str()); + + // If it doesn't exist, we're done. + if (attr == INVALID_FILE_ATTRIBUTES) + return; + + if (attr & FILE_ATTRIBUTE_READONLY) { + if (!SetFileAttributes(path.c_str(), attr & ~FILE_ATTRIBUTE_READONLY)) + ThrowError(std::string(path) + ": Can't make file writable: "); + } } void Path::makeExecutable() { + // All files are executable on Windows (ignoring security attributes). } bool |