From 4ac566c3084257f23af49ffdb4dd481daff8cfb9 Mon Sep 17 00:00:00 2001 From: Christopher Snowhill Date: Mon, 20 Jun 2022 23:39:07 -0700 Subject: [PATCH] [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 --- Utils/SandboxBroker.m | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Utils/SandboxBroker.m b/Utils/SandboxBroker.m index 8c4b33078..fe50ba6d7 100644 --- a/Utils/SandboxBroker.m +++ b/Utils/SandboxBroker.m @@ -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];