As a general rule, use fileSystemRepresentation if passing NSStrings to lower-level open commands.

This will be especially true for APFS volumes.
This commit is contained in:
C.W. Betts
2017-07-02 15:30:54 -06:00
parent 56a1f766e2
commit 44b586fe90

View File

@@ -186,7 +186,7 @@ void beep() {
}
void launchURL(std::string url) {
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:[NSString stringWithCString:url.c_str() encoding:NSUTF8StringEncoding]]];
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:[NSString stringWithUTF8String:url.c_str()]]];
}
int getMenubarHeight() {
@@ -242,7 +242,7 @@ fs::path nav_get_scenario() {
bool gotFile = [dlg_get_scen runModal] != NSFileHandlingPanelCancelButton;
makeFrontWindow(mainPtr);
if(gotFile) {
return fs::path([[[[dlg_get_scen URL] absoluteURL] path] UTF8String]);
return fs::path([[[dlg_get_scen URL] path] fileSystemRepresentation]);
}
return "";
}
@@ -256,7 +256,7 @@ fs::path nav_put_scenario(fs::path def) {
bool gotFile = [dlg_put_scen runModal] != NSFileHandlingPanelCancelButton;
makeFrontWindow(mainPtr);
if(gotFile)
return fs::path([[[[dlg_put_scen URL] absoluteURL] path] UTF8String]);
return fs::path([[[dlg_put_scen URL] path] fileSystemRepresentation]);
return "";
}
@@ -264,7 +264,7 @@ fs::path nav_get_party() {
bool gotFile = [dlg_get_game runModal] != NSFileHandlingPanelCancelButton;
makeFrontWindow(mainPtr);
if(gotFile)
return fs::path([[[[dlg_get_game URL] absoluteURL] path] UTF8String]);
return fs::path([[[dlg_get_game URL] path] fileSystemRepresentation]);
return "";
}
@@ -277,20 +277,21 @@ fs::path nav_put_party(fs::path def) {
bool gotFile = [dlg_put_game runModal] != NSFileHandlingPanelCancelButton;
makeFrontWindow(mainPtr);
if(gotFile)
return fs::path([[[[dlg_put_game URL] absoluteURL] path] UTF8String]);
return fs::path([[[dlg_put_game URL] path] fileSystemRepresentation]);
return "";
}
fs::path nav_get_rsrc(std::initializer_list<std::string> extensions) {
NSMutableArray* allowTypes = [NSMutableArray arrayWithCapacity: extensions.size()];
NSMutableArray* allowTypes = [[NSMutableArray alloc] initWithCapacity: extensions.size()];
for(std::string ext : extensions) {
NSString* the_ext = [NSString stringWithUTF8String: ext.c_str()];
[allowTypes addObject: the_ext];
}
[dlg_get_rsrc setAllowedFileTypes: allowTypes];
[allowTypes release];
bool gotFile = [dlg_get_rsrc runModal] != NSFileHandlingPanelCancelButton;
if(gotFile)
return fs::path([[[[dlg_get_rsrc URL] absoluteURL] path] UTF8String]);
return fs::path([[[dlg_get_rsrc URL] path] fileSystemRepresentation]);
return "";
}
@@ -308,7 +309,7 @@ fs::path nav_put_rsrc(std::initializer_list<std::string> extensions, fs::path de
[dlg_put_rsrc setAllowedFileTypes: allowTypes];
bool gotFile = [dlg_put_rsrc runModal] != NSFileHandlingPanelCancelButton;
if(gotFile)
return fs::path([[[[dlg_put_rsrc URL] absoluteURL] path] UTF8String]);
return fs::path([[[dlg_put_rsrc URL] path] fileSystemRepresentation]);
return "";
}