[Sandbox Broker] Allow to be passed directory URLs

Allow opening directory URLs as-is, rather than treating them like
files. Return the full path if the caller requests opening on a
directory.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
swiftingly
Christopher Snowhill 2022-06-20 23:39:07 -07:00
parent a1ab3deec4
commit 4ac566c308
1 changed files with 8 additions and 0 deletions

View File

@ -30,6 +30,14 @@ static SandboxBroker *__sharedSandboxBroker = nil;
@end
static NSURL *urlWithoutFragment(NSURL *u) {
if(![u isFileURL]) return u;
NSNumber *isDirectory;
BOOL success = [u getResourceValue:&isDirectory forKey:NSURLIsDirectoryKey error:nil];
if(success && [isDirectory boolValue]) return u;
NSString *s = [u path];
NSString *lastComponent = [u lastPathComponent];