Skip to content

Commit

Permalink
hiro/cocoa: Ensure trailing slash in directory picker result
Browse files Browse the repository at this point in the history
  • Loading branch information
jcm93 authored and LukeUsher committed Feb 10, 2025
1 parent 1d5a5ae commit c19cf47
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions hiro/cocoa/browser-window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@ auto pBrowserWindow::directory(BrowserWindow::State& state) -> string {
if(state.title) [panel setTitle:[NSString stringWithUTF8String:state.title]];
panel.canChooseDirectories = YES;
panel.canChooseFiles = NO;
panel.canCreateDirectories = YES;
panel.directoryURL = [NSURL fileURLWithPath:[NSString stringWithUTF8String:state.path]];
if([panel runModal] == NSModalResponseOK) {
NSArray* files = [panel URLs];
const char* path = [[[files objectAtIndex:0] path] UTF8String];
if(path) result = path;
NSString* path = panel.URLs.firstObject.path;
if(path) {
path = [path stringByAppendingString:@"/"];
result = path.UTF8String;
}
}
}

Expand Down

0 comments on commit c19cf47

Please sign in to comment.