summaryrefslogtreecommitdiff
path: root/lib/System/Win32
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2007-03-29 16:43:20 +0000
committerReid Spencer <rspencer@reidspencer.com>2007-03-29 16:43:20 +0000
commit69cce815e7414ad9a186920c78890c852986d6bf (patch)
tree1e40f9377343d63797382c56cda19544249b599f /lib/System/Win32
parent585e0882c38516b52e67eb0b22c91c72c10ce9a4 (diff)
downloadllvm-69cce815e7414ad9a186920c78890c852986d6bf.tar.gz
llvm-69cce815e7414ad9a186920c78890c852986d6bf.tar.bz2
llvm-69cce815e7414ad9a186920c78890c852986d6bf.tar.xz
For PR789:
* Add a method: bool isAbsolute() const, which determines if the path name is absolute or not. * Implement caching of file status information in the Path object. Allow it to be updated forcefully or lazily re-fetched from the cached value. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35456 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/System/Win32')
-rw-r--r--lib/System/Win32/Path.inc41
1 files changed, 27 insertions, 14 deletions
diff --git a/lib/System/Win32/Path.inc b/lib/System/Win32/Path.inc
index 1eee2bb3c1..1f809ecfa5 100644
--- a/lib/System/Win32/Path.inc
+++ b/lib/System/Win32/Path.inc
@@ -105,6 +105,13 @@ Path::isValid() const {
return true;
}
+bool
+Path::isAbsolute() const {
+ if (path.length() < 3)
+ return false;
+ return path[0] == 'C' && path[1] == ':' && path[2] == '\\';
+}
+
static Path *TempDirectory = NULL;
Path
@@ -294,24 +301,30 @@ Path::getLast() const {
}
bool
-Path::getFileStatus(FileStatus &info, std::string *ErrStr) const {
- WIN32_FILE_ATTRIBUTE_DATA fi;
- if (!GetFileAttributesEx(path.c_str(), GetFileExInfoStandard, &fi))
- return MakeErrMsg(ErrStr, "getStatusInfo():" + std::string(path) +
- ": Can't get status: ");
+Path::getFileStatus(FileStatus &info, bool update, std::string *ErrStr) const {
+ if (status == 0 || update) {
+ WIN32_FILE_ATTRIBUTE_DATA fi;
+ if (!GetFileAttributesEx(path.c_str(), GetFileExInfoStandard, &fi))
+ return MakeErrMsg(ErrStr, "getStatusInfo():" + std::string(path) +
+ ": Can't get status: ");
- info.fileSize = fi.nFileSizeHigh;
- info.fileSize <<= sizeof(fi.nFileSizeHigh)*8;
- info.fileSize += fi.nFileSizeLow;
+ if (status == 0)
+ status = new FileStatus;
- info.mode = fi.dwFileAttributes & FILE_ATTRIBUTE_READONLY ? 0555 : 0777;
- info.user = 9999; // Not applicable to Windows, so...
- info.group = 9999; // Not applicable to Windows, so...
+ status->fileSize = fi.nFileSizeHigh;
+ status->fileSize <<= sizeof(fi.nFileSizeHigh)*8;
+ status->fileSize += fi.nFileSizeLow;
- __int64 ft = *reinterpret_cast<__int64*>(&fi.ftLastWriteTime);
- info.modTime.fromWin32Time(ft);
+ status->mode = fi.dwFileAttributes & FILE_ATTRIBUTE_READONLY ? 0555 : 0777;
+ status->user = 9999; // Not applicable to Windows, so...
+ status->group = 9999; // Not applicable to Windows, so...
- info.isDir = fi.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY;
+ __int64 ft = *reinterpret_cast<__int64*>(&fi.ftLastWriteTime);
+ status->modTime.fromWin32Time(ft);
+
+ status->isDir = fi.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY;
+ }
+ info = *status;
return false;
}