summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2018-08-09 11:52:45 (GMT)
committerKitware Robot <kwrobot@kitware.com>2018-08-09 11:53:49 (GMT)
commit575f06e48c456c3b556fe6f70d0e3b23a3830e3c (patch)
tree4572c7099ca95a909db78b4876bdb9b83d073f3f
parent1c773b5d3aae0ad2146b1076ae8e00166f49a849 (diff)
parentba872ea9c372b207d4fadaea7edc235c212e9a85 (diff)
downloadCMake-575f06e48c456c3b556fe6f70d0e3b23a3830e3c.zip
CMake-575f06e48c456c3b556fe6f70d0e3b23a3830e3c.tar.gz
CMake-575f06e48c456c3b556fe6f70d0e3b23a3830e3c.tar.bz2
Merge topic 'update-kwsys'
ba872ea9c3 Merge branch 'upstream-KWSys' into update-kwsys 4d76239a51 KWSys 2018-08-07 (9044518f) Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !2268
-rw-r--r--Source/kwsys/SystemTools.cxx24
1 files changed, 21 insertions, 3 deletions
diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx
index d552d9f..476fe08 100644
--- a/Source/kwsys/SystemTools.cxx
+++ b/Source/kwsys/SystemTools.cxx
@@ -1197,9 +1197,27 @@ bool SystemTools::FileExists(const std::string& filename)
}
return access(filename.c_str(), R_OK) == 0;
#elif defined(_WIN32)
- return (
- GetFileAttributesW(Encoding::ToWindowsExtendedPath(filename).c_str()) !=
- INVALID_FILE_ATTRIBUTES);
+ DWORD attr =
+ GetFileAttributesW(Encoding::ToWindowsExtendedPath(filename).c_str());
+ if (attr == INVALID_FILE_ATTRIBUTES) {
+ return false;
+ }
+
+ if (attr & FILE_ATTRIBUTE_REPARSE_POINT) {
+ // Using 0 instead of GENERIC_READ as it allows reading of file attributes
+ // even if we do not have permission to read the file itself
+ HANDLE handle =
+ CreateFileW(Encoding::ToWindowsExtendedPath(filename).c_str(), 0, 0,
+ NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
+
+ if (handle == INVALID_HANDLE_VALUE) {
+ return false;
+ }
+
+ CloseHandle(handle);
+ }
+
+ return true;
#else
// SCO OpenServer 5.0.7/3.2's command has 711 permission.
# if defined(_SCO_DS)