[llvm-commits] CVS: llvm/lib/System/Win32/Path.inc

Reid Spencer reid at x10sys.com
Thu Mar 29 09:43:42 PDT 2007



Changes in directory llvm/lib/System/Win32:

Path.inc updated: 1.59 -> 1.60
---
Log message:

For PR789: http://llvm.org/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.


---
Diffs of the changes:  (+29 -16)

 Path.inc |   45 +++++++++++++++++++++++++++++----------------
 1 files changed, 29 insertions(+), 16 deletions(-)


Index: llvm/lib/System/Win32/Path.inc
diff -u llvm/lib/System/Win32/Path.inc:1.59 llvm/lib/System/Win32/Path.inc:1.60
--- llvm/lib/System/Win32/Path.inc:1.59	Sun Nov  5 13:31:28 2006
+++ llvm/lib/System/Win32/Path.inc	Thu Mar 29 11:43:20 2007
@@ -105,6 +105,13 @@
   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 @@
 }
 
 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: ");
-
-  info.fileSize = fi.nFileSizeHigh;
-  info.fileSize <<= sizeof(fi.nFileSizeHigh)*8;
-  info.fileSize += fi.nFileSizeLow;
-
-  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...
+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: ");
+
+    if (status == 0)
+      status = new FileStatus;
+
+    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...
 
-  __int64 ft = *reinterpret_cast<__int64*>(&fi.ftLastWriteTime);
-  info.modTime.fromWin32Time(ft);
+    __int64 ft = *reinterpret_cast<__int64*>(&fi.ftLastWriteTime);
+    status->modTime.fromWin32Time(ft);
 
-  info.isDir = fi.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY;
+    status->isDir = fi.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY;
+  }
+  info = *status;
   return false;
 }
 






More information about the llvm-commits mailing list