dialog: fix default file name on Cocoa

This commit is contained in:
Anon Ymous
2025-07-21 15:51:35 -04:00
committed by Ryan C. Gordon
parent fc19ae343c
commit b2d152e51f
+8 -1
View File
@@ -158,7 +158,14 @@ void SDL_SYS_ShowFileDialogWithProperties(SDL_FileDialogType type, SDL_DialogFil
[dialog setAllowsOtherFileTypes:YES];
if (default_location) {
[dialog setDirectoryURL:[NSURL fileURLWithPath:[NSString stringWithUTF8String:default_location]]];
char last = default_location[SDL_strlen(default_location) - 1];
NSURL* url = [NSURL fileURLWithPath:[NSString stringWithUTF8String:default_location]];
if (last == '/') {
[dialog setDirectoryURL:url];
} else {
[dialog setDirectoryURL:[url URLByDeletingLastPathComponent]];
[dialog setNameFieldStringValue:[url lastPathComponent]];
}
}
NSWindow *w = NULL;