mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-11-01 00:17:01 +00:00
Fix destroyDirectory bug
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19746 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -562,15 +562,17 @@ Path::destroyDirectory(bool remove_contents) const {
|
|||||||
// If it doesn't exist, we're done.
|
// If it doesn't exist, we're done.
|
||||||
if (!exists()) return true;
|
if (!exists()) return true;
|
||||||
|
|
||||||
char *pathname = reinterpret_cast<char *>(_alloca(path.length()+1));
|
char *pathname = reinterpret_cast<char *>(_alloca(path.length()+2));
|
||||||
path.copy(pathname,path.length()+1);
|
|
||||||
int lastchar = path.length() - 1 ;
|
int lastchar = path.length() - 1 ;
|
||||||
if (pathname[lastchar] == '/')
|
path.copy(pathname,lastchar+2);
|
||||||
pathname[lastchar] = 0;
|
|
||||||
|
// Make path end with '/*'.
|
||||||
|
pathname[lastchar+1] = '*';
|
||||||
|
pathname[lastchar+2] = 0;
|
||||||
|
|
||||||
if (remove_contents) {
|
if (remove_contents) {
|
||||||
WIN32_FIND_DATA fd;
|
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
|
// 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.
|
// 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))
|
if (!RemoveDirectory(pathname))
|
||||||
ThrowError(std::string(pathname) + ": Can't destroy directory: ");
|
ThrowError(std::string(pathname) + ": Can't destroy directory: ");
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user