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

Jeff Cohen jeffc at jolt-lang.org
Sat Apr 7 13:47:45 PDT 2007



Changes in directory llvm/lib/System/Win32:

Path.inc updated: 1.64 -> 1.65
Signals.inc updated: 1.23 -> 1.24
---
Log message:

Unbreak VC++ build.

---
Diffs of the changes:  (+32 -32)

 Path.inc    |   53 +++++++++++++++++++++++++----------------------------
 Signals.inc |   11 +++++++----
 2 files changed, 32 insertions(+), 32 deletions(-)


Index: llvm/lib/System/Win32/Path.inc
diff -u llvm/lib/System/Win32/Path.inc:1.64 llvm/lib/System/Win32/Path.inc:1.65
--- llvm/lib/System/Win32/Path.inc:1.64	Sat Apr  7 13:52:17 2007
+++ llvm/lib/System/Win32/Path.inc	Sat Apr  7 15:47:27 2007
@@ -368,11 +368,15 @@
 
 bool
 Path::getDirectoryContents(std::set<Path>& result, std::string* ErrMsg) const {
-  const FileStatus *Status = getFileStatus(false, ErrMsg);
-  if (!Status)
+  WIN32_FILE_ATTRIBUTE_DATA fi;
+  if (!GetFileAttributesEx(path.c_str(), GetFileExInfoStandard, &fi)) {
+    MakeErrMsg(ErrMsg, path + ": can't get status of file");
     return true;
-  if (!Status->isDir) {
-    MakeErrMsg(ErrMsg, path + ": not a directory");
+  }
+    
+  if (!(fi.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
+    if (ErrMsg)
+      *ErrMsg = path + ": not a directory";
     return true;
   }
 
@@ -565,28 +569,11 @@
 
 bool
 Path::eraseFromDisk(bool remove_contents, std::string *ErrStr) const {
-  const FileStatus *Status = getFileStatus(false, ErrStr);
-  if (!Status)
-    return false;
+  WIN32_FILE_ATTRIBUTE_DATA fi;
+  if (!GetFileAttributesEx(path.c_str(), GetFileExInfoStandard, &fi))
+    return true;
     
-  if (Status->isFile) {
-    DWORD attr = GetFileAttributes(path.c_str());
-
-    // If it doesn't exist, we're done.
-    if (attr == INVALID_FILE_ATTRIBUTES)
-      return false;
-
-    // Read-only files cannot be deleted on Windows.  Must remove the read-only
-    // attribute first.
-    if (attr & FILE_ATTRIBUTE_READONLY) {
-      if (!SetFileAttributes(path.c_str(), attr & ~FILE_ATTRIBUTE_READONLY))
-        return MakeErrMsg(ErrStr, path + ": Can't destroy file: ");
-    }
-
-    if (!DeleteFile(path.c_str()))
-      return MakeErrMsg(ErrStr, path + ": Can't destroy file: ");
-    return false;
-  } else if (Status->isDir) {
+  if (fi.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
     // If it doesn't exist, we're done.
     if (!exists())
       return false;
@@ -645,9 +632,19 @@
       return MakeErrMsg(ErrStr, 
         std::string(pathname) + ": Can't destroy directory: ");
     return false;
-  } 
-  // It appears the path doesn't exist.
-  return true;
+  } else {
+    // Read-only files cannot be deleted on Windows.  Must remove the read-only
+    // attribute first.
+    if (fi.dwFileAttributes & FILE_ATTRIBUTE_READONLY) {
+      if (!SetFileAttributes(path.c_str(),
+                             fi.dwFileAttributes & ~FILE_ATTRIBUTE_READONLY))
+        return MakeErrMsg(ErrStr, path + ": Can't destroy file: ");
+    }
+
+    if (!DeleteFile(path.c_str()))
+      return MakeErrMsg(ErrStr, path + ": Can't destroy file: ");
+    return false;
+  }
 }
 
 bool Path::getMagicNumber(std::string& Magic, unsigned len) const {


Index: llvm/lib/System/Win32/Signals.inc
diff -u llvm/lib/System/Win32/Signals.inc:1.23 llvm/lib/System/Win32/Signals.inc:1.24
--- llvm/lib/System/Win32/Signals.inc:1.23	Thu Mar 29 14:05:44 2007
+++ llvm/lib/System/Win32/Signals.inc	Sat Apr  7 15:47:27 2007
@@ -101,12 +101,15 @@
 // RemoveDirectoryOnSignal - The public API
 bool sys::RemoveDirectoryOnSignal(const sys::Path& path, std::string* ErrMsg) {
   // Not a directory?
-  const sys::FileStatus *Status =  path.getFileStatus(false, ErrMsg);
-  if (!Status)
+  WIN32_FILE_ATTRIBUTE_DATA fi;
+  if (!GetFileAttributesEx(path.c_str(), GetFileExInfoStandard, &fi)) {
+    MakeErrMsg(ErrMsg, path.toString() + ": can't get status of file");
     return true;
-  if (!Status->isDir) {
+  }
+    
+  if (!(fi.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
     if (ErrMsg)
-      *ErrMsg = path.toString() + " is not a directory";
+      *ErrMsg = path.toString() + ": not a directory";
     return true;
   }
 






More information about the llvm-commits mailing list