Skip to content

Commit d41d553

Browse files
authored
Merge pull request swiftlang#2663 from compnerd/ceci-nest-pas-une-directoire
CoreFoundation: handle `isDirectory` properly in `WindowsPathToURLPath`
2 parents 6167997 + 45fea3c commit d41d553

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Diff for: CoreFoundation/URL.subproj/CFURL.c

+7
Original file line numberDiff line numberDiff line change
@@ -3977,6 +3977,13 @@ static CFArrayRef WindowsPathToURLComponents(CFStringRef path, CFAllocatorRef al
39773977
urlComponents = CFArrayCreateMutableCopy(alloc, 0, tmp);
39783978
CFRelease(tmp);
39793979

3980+
if (isDir == FALSE) {
3981+
CFIndex last = CFArrayGetCount(urlComponents) - 1;
3982+
if (CFEqual(CFArrayGetValueAtIndex(urlComponents, last), CFSTR(""))) {
3983+
CFArrayRemoveValueAtIndex(urlComponents, last);
3984+
}
3985+
}
3986+
39803987
CFStringRef str = (CFStringRef)CFArrayGetValueAtIndex(urlComponents, 0);
39813988
if (isAbsolute && CFStringGetLength(str) == 2 && CFStringGetCharacterAtIndex(str, 1) == ':') {
39823989
i = 1; // Skip over the drive letter

0 commit comments

Comments
 (0)