Skip to content
Snippets Groups Projects
Commit 7a5e5af8 authored by Brad King's avatar Brad King
Browse files

SystemTools: Revert "Fix FileIsSymlink with Windows data deduplication"

This reverts commit ef373416 (SystemTools: Fix FileIsSymlink with
Windows data deduplication, 2019-01-18).  It regressed `FileIsSymlink`
such that it does not always recognize broken symlinks as symlinks.

Revert pending further investigation.  Notes for re-introduction:

* We need to add a test to cover the case that broke.
* We should save the Encoding::ToWindowsExtendedPath result and
  use it for both GetFileAttributesW and CreateFileW instead of
  using Encoding::ToWide for the latter.
parent ef373416
No related branches found
No related tags found
1 merge request!120SystemTools: Revert "Fix FileIsSymlink with Windows data deduplication"
......@@ -2982,28 +2982,7 @@ bool SystemTools::FileIsSymlink(const std::string& name)
DWORD attr =
GetFileAttributesW(Encoding::ToWindowsExtendedPath(name).c_str());
if (attr != INVALID_FILE_ATTRIBUTES) {
if ((attr & FILE_ATTRIBUTE_REPARSE_POINT) != 0) {
HANDLE hFile = CreateFileW(Encoding::ToWide(name).c_str(), GENERIC_READ,
FILE_SHARE_READ, NULL, OPEN_EXISTING,
FILE_FLAG_BACKUP_SEMANTICS, NULL);
if (hFile == INVALID_HANDLE_VALUE) {
return false;
}
byte buffer[MAXIMUM_REPARSE_DATA_BUFFER_SIZE];
DWORD bytesReturned = 0;
if (!DeviceIoControl(hFile, FSCTL_GET_REPARSE_POINT, NULL, 0, buffer,
MAXIMUM_REPARSE_DATA_BUFFER_SIZE, &bytesReturned,
NULL)) {
CloseHandle(hFile);
return false;
}
CloseHandle(hFile);
ULONG reparseTag =
reinterpret_cast<PREPARSE_GUID_DATA_BUFFER>(&buffer[0])->ReparseTag;
return (reparseTag == IO_REPARSE_TAG_SYMLINK) ||
(reparseTag == IO_REPARSE_TAG_MOUNT_POINT);
}
return false;
return (attr & FILE_ATTRIBUTE_REPARSE_POINT) != 0;
} else {
return false;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment