aboutsummaryrefslogtreecommitdiffstats
path: root/lib/System/Win32/Path.inc
diff options
context:
space:
mode:
authorJeff Cohen <jeffc@jolt-lang.org>2005-01-22 16:28:33 +0000
committerJeff Cohen <jeffc@jolt-lang.org>2005-01-22 16:28:33 +0000
commitc690cc046555c3fbb5d07fde19233f29f8d71dcd (patch)
tree8c8f07fb51fcb6b6487d2e142698ae5575167ce8 /lib/System/Win32/Path.inc
parent5037a1591070247af4f83316ec479829846cc734 (diff)
downloadexternal_llvm-c690cc046555c3fbb5d07fde19233f29f8d71dcd.zip
external_llvm-c690cc046555c3fbb5d07fde19233f29f8d71dcd.tar.gz
external_llvm-c690cc046555c3fbb5d07fde19233f29f8d71dcd.tar.bz2
Fix destroyDirectory bug
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19746 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/System/Win32/Path.inc')
-rw-r--r--lib/System/Win32/Path.inc13
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/System/Win32/Path.inc b/lib/System/Win32/Path.inc
index 7f891f4..a28fd82 100644
--- a/lib/System/Win32/Path.inc
+++ b/lib/System/Win32/Path.inc
@@ -562,15 +562,17 @@ Path::destroyDirectory(bool remove_contents) const {
// 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 @@ Path::destroyDirectory(bool remove_contents) const {
}
}
+ pathname[lastchar] = 0;
if (!RemoveDirectory(pathname))
ThrowError(std::string(pathname) + ": Can't destroy directory: ");
return true;