Skip to content

Commit 08d50c1

Browse files
FoundationEssentials: correct path canonicalisation handling on Windows (#639)
* FoundationEssentials: correct path canonicalisation handling on Windows Strip the extended path prefix for bypassing the Win32 API layer. This is guaranteed to be prefixed on strings as per the documentation. * Update Sources/FoundationEssentials/String/String+Path.swift Co-authored-by: Jeremy Schonfeld <[email protected]> --------- Co-authored-by: Jeremy Schonfeld <[email protected]>
1 parent 3297fb3 commit 08d50c1

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Sources/FoundationEssentials/String/String+Path.swift

+3-1
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,9 @@ extension String {
665665
guard GetFinalPathNameByHandleW(hFile, $0.baseAddress, dwLength, VOLUME_NAME_DOS) == dwLength - 1 else {
666666
return nil
667667
}
668-
return String(decodingCString: $0.baseAddress!, as: UTF16.self)
668+
669+
// When using `VOLUME_NAME_DOS`, the returned path uses `\\?\`.
670+
return String(decodingCString: $0.baseAddress!.advanced(by: 4), as: UTF16.self)
669671
}
670672
}
671673
#else

0 commit comments

Comments
 (0)