Skip to content

Commit 545cc23

Browse files
authored
Merge pull request #2547 from gmittert/TrailingSlash
Respect appendSlashForDirectories on Windows in _CFIterateDirectory
2 parents 3b47193 + 5bd6c2d commit 545cc23

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

CoreFoundation/Base.subproj/CFFileUtilities.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1056,9 +1056,13 @@ CF_PRIVATE void _CFIterateDirectory(CFStringRef directoryPath, Boolean appendSla
10561056
}
10571057

10581058
assert(!stuffToPrefix && "prefix not yet implemented");
1059-
CFStringRef filePath = CFRetain(fileName);
1060-
10611059
Boolean isDirectory = file.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY;
1060+
CFMutableStringRef filePath = CFStringCreateMutableCopy(kCFAllocatorSystemDefault, nameLen + 1, fileName);
1061+
if (appendSlashForDirectories && isDirectory) {
1062+
UniChar slash = CFPreferredSlash;
1063+
CFStringAppendCharacters(filePath, &slash, 1);
1064+
}
1065+
10621066
Boolean result = fileHandler(fileName, filePath, isDirectory ? DT_DIR : DT_REG);
10631067
CFRelease(fileName);
10641068
CFRelease(filePath);

0 commit comments

Comments
 (0)