Skip to content

Commit 0074e07

Browse files
authored
Merge pull request #2409 from gmittert/FromThereNotHere
[Windows] Fix _fileExists for relative links
2 parents 5efac49 + 79bf014 commit 0074e07

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

Foundation/FileManager+Win32.swift

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,15 @@ extension FileManager {
548548
var faAttributes: WIN32_FILE_ATTRIBUTE_DATA = WIN32_FILE_ATTRIBUTE_DATA()
549549
do { faAttributes = try windowsFileAttributes(atPath: path) } catch { return false }
550550
if faAttributes.dwFileAttributes & DWORD(FILE_ATTRIBUTE_REPARSE_POINT) == DWORD(FILE_ATTRIBUTE_REPARSE_POINT) {
551-
do { try faAttributes = windowsFileAttributes(atPath: destinationOfSymbolicLink(atPath: path)) } catch { return false }
551+
do {
552+
let contents = try destinationOfSymbolicLink(atPath: path)
553+
let resolvedPath = contents.isAbsolutePath
554+
? contents
555+
: joinPath(prefix: path.deletingLastPathComponent, suffix: contents)
556+
try faAttributes = windowsFileAttributes(atPath: resolvedPath)
557+
} catch {
558+
return false
559+
}
552560
}
553561
if let isDirectory = isDirectory {
554562
isDirectory.pointee = ObjCBool(faAttributes.dwFileAttributes & DWORD(FILE_ATTRIBUTE_DIRECTORY) == DWORD(FILE_ATTRIBUTE_DIRECTORY))

0 commit comments

Comments
 (0)