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

Jeff Cohen jeffc at jolt-lang.org
Sat Jan 22 08:28:44 PST 2005



Changes in directory llvm/lib/System/Win32:

Path.inc updated: 1.28 -> 1.29
---
Log message:

Fix destroyDirectory bug

---
Diffs of the changes:  (+8 -5)

 Path.inc |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)


Index: llvm/lib/System/Win32/Path.inc
diff -u llvm/lib/System/Win32/Path.inc:1.28 llvm/lib/System/Win32/Path.inc:1.29
--- llvm/lib/System/Win32/Path.inc:1.28	Thu Jan 13 22:09:39 2005
+++ llvm/lib/System/Win32/Path.inc	Sat Jan 22 10:28:33 2005
@@ -562,15 +562,17 @@
   // If it doesn't exist, we're done.
   if (!exists()) return true;
 
-  char *pathname = reinterpret_cast<char *>(_alloca(path.length()+1));
-  path.copy(pathname,path.length()+1);
+  char *pathname = reinterpret_cast<char *>(_alloca(path.length()+2));
   int lastchar = path.length() - 1 ;
-  if (pathname[lastchar] == '/')
-    pathname[lastchar] = 0;
+  path.copy(pathname,lastchar+2);
+
+  // Make path end with '/*'.
+  pathname[lastchar+1] = '*';
+  pathname[lastchar+2] = 0;
 
   if (remove_contents) {
     WIN32_FIND_DATA fd;
-    HANDLE h = FindFirstFile(path.c_str(), &fd);
+    HANDLE h = FindFirstFile(pathname, &fd);
 
     // It's a bad idea to alter the contents of a directory while enumerating
     // its contents.  So build a list of its contents first, then destroy them.
@@ -610,6 +612,7 @@
     }
   }
 
+  pathname[lastchar] = 0;
   if (!RemoveDirectory(pathname))
     ThrowError(std::string(pathname) + ": Can't destroy directory: ");
   return true;






More information about the llvm-commits mailing list