aboutsummaryrefslogtreecommitdiffstats
path: root/lib/System/Win32
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2007-04-07 18:52:17 +0000
committerReid Spencer <rspencer@reidspencer.com>2007-04-07 18:52:17 +0000
commit2ae9d11b7c0fd54e0b5298fb4fcf17b6ee9d5c91 (patch)
tree47499784611ea34bf3d97785c62b6eebf4a7057d /lib/System/Win32
parente9ed4452bce4f5a7f8005d7ebd649a20c22ef268 (diff)
downloadexternal_llvm-2ae9d11b7c0fd54e0b5298fb4fcf17b6ee9d5c91.zip
external_llvm-2ae9d11b7c0fd54e0b5298fb4fcf17b6ee9d5c91.tar.gz
external_llvm-2ae9d11b7c0fd54e0b5298fb4fcf17b6ee9d5c91.tar.bz2
For PR1291:
Implement the PathWithStatus class and its use throughout lib/System. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35742 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/System/Win32')
-rw-r--r--lib/System/Win32/Path.inc30
1 files changed, 14 insertions, 16 deletions
diff --git a/lib/System/Win32/Path.inc b/lib/System/Win32/Path.inc
index 57d7535..937bb51 100644
--- a/lib/System/Win32/Path.inc
+++ b/lib/System/Win32/Path.inc
@@ -307,8 +307,8 @@ Path::getLast() const {
}
const FileStatus *
-Path::getFileStatus(bool update, std::string *ErrStr) const {
- if (status == 0 || update) {
+PathWithStatus::getFileStatus(bool update, std::string *ErrStr) const {
+ if (!fsIsValid || update) {
WIN32_FILE_ATTRIBUTE_DATA fi;
if (!GetFileAttributesEx(path.c_str(), GetFileExInfoStandard, &fi)) {
MakeErrMsg(ErrStr, "getStatusInfo():" + std::string(path) +
@@ -316,30 +316,28 @@ Path::getFileStatus(bool update, std::string *ErrStr) const {
return 0;
}
- if (status == 0)
- status = new FileStatus;
+ status.fileSize = fi.nFileSizeHigh;
+ status.fileSize <<= sizeof(fi.nFileSizeHigh)*8;
+ status.fileSize += fi.nFileSizeLow;
- status->fileSize = fi.nFileSizeHigh;
- status->fileSize <<= sizeof(fi.nFileSizeHigh)*8;
- status->fileSize += fi.nFileSizeLow;
-
- 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...
+ 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...
// FIXME: this is only unique if the file is accessed by the same file path.
// How do we do this for C:\dir\file and ..\dir\file ? Unix has inode
// numbers, but the concept doesn't exist in Windows.
- status->uniqueID = 0;
+ status.uniqueID = 0;
for (unsigned i = 0; i < path.length(); ++i)
- status->uniqueID += path[i];
+ status.uniqueID += path[i];
__int64 ft = *reinterpret_cast<__int64*>(&fi.ftLastWriteTime);
- status->modTime.fromWin32Time(ft);
+ status.modTime.fromWin32Time(ft);
- status->isDir = fi.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY;
+ status.isDir = fi.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY;
+ fsIsValid = true;
}
- return status;
+ return &status;
}
bool Path::makeReadableOnDisk(std::string* ErrMsg) {