Commit 8f755ee9 authored by Brad King's avatar Brad King Committed by Kitware Robot

Merge topic 'remove-windows-directory-soft-links'

9f6cd407 SystemTools: Fix removing of soft links to directories on Windows.
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Merge-request: !77
parents 3ba214b7 9f6cd407
......@@ -2509,6 +2509,14 @@ bool SystemTools::RemoveFile(const std::string& source)
if (IsJunction(ws) && DeleteJunction(ws)) {
return true;
}
const DWORD DIRECTORY_SOFT_LINK_ATTRS =
FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_REPARSE_POINT;
DWORD attrs = GetFileAttributesW(ws.c_str());
if (attrs != INVALID_FILE_ATTRIBUTES &&
(attrs & DIRECTORY_SOFT_LINK_ATTRS) == DIRECTORY_SOFT_LINK_ATTRS &&
RemoveDirectoryW(ws.c_str())) {
return true;
}
if (DeleteFileW(ws.c_str()) || GetLastError() == ERROR_FILE_NOT_FOUND ||
GetLastError() == ERROR_PATH_NOT_FOUND) {
return true;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment