[Sandbox] Compare to the actual user paths
Remove the sandbox reference, because the user will add folders outside the sandbox, and we have entitlements to access these folders. Signed-off-by: Christopher Snowhill <kode54@gmail.com>swiftingly
parent
96a7255779
commit
c2ef7d0e61
|
@ -19,12 +19,18 @@
|
|||
|
||||
static void *kFileTreeDataSourceContext = &kFileTreeDataSourceContext;
|
||||
|
||||
// XXX this is only for reference, we have the entitlement for the path anyway
|
||||
static NSURL *pathEscape(NSString *path) {
|
||||
NSString *componentsToRemove = [NSString stringWithFormat:@"Library/Containers/%@/Data/", [[NSBundle mainBundle] bundleIdentifier]];
|
||||
NSRange rangeOfMatch = [path rangeOfString:componentsToRemove];
|
||||
if(rangeOfMatch.location != NSNotFound)
|
||||
path = [path stringByReplacingCharactersInRange:rangeOfMatch withString:@""];
|
||||
return [NSURL fileURLWithPath:path];
|
||||
}
|
||||
|
||||
static NSURL *defaultMusicDirectory(void) {
|
||||
return [[NSFileManager defaultManager] URLForDirectory:NSMusicDirectory
|
||||
inDomain:NSUserDomainMask
|
||||
appropriateForURL:nil
|
||||
create:NO
|
||||
error:nil];
|
||||
NSString *path = [NSSearchPathForDirectoriesInDomains(NSMusicDirectory, NSUserDomainMask, YES) lastObject];
|
||||
return pathEscape(path);
|
||||
}
|
||||
|
||||
@interface FileTreeDataSource ()
|
||||
|
|
|
@ -18,28 +18,28 @@
|
|||
@property(nonatomic) NSURL *_Nullable url;
|
||||
@end
|
||||
|
||||
// XXX this is only for comparison, not "escaping the sandbox"
|
||||
static NSURL *pathEscape(NSString *path) {
|
||||
NSString *componentsToRemove = [NSString stringWithFormat:@"Library/Containers/%@/Data/", [[NSBundle mainBundle] bundleIdentifier]];
|
||||
NSRange rangeOfMatch = [path rangeOfString:componentsToRemove];
|
||||
if(rangeOfMatch.location != NSNotFound)
|
||||
path = [path stringByReplacingCharactersInRange:rangeOfMatch withString:@""];
|
||||
return [NSURL fileURLWithPath:path];
|
||||
}
|
||||
|
||||
static NSURL *defaultMusicDirectory(void) {
|
||||
return [[NSFileManager defaultManager] URLForDirectory:NSMusicDirectory
|
||||
inDomain:NSUserDomainMask
|
||||
appropriateForURL:nil
|
||||
create:NO
|
||||
error:nil];
|
||||
NSString *path = [NSSearchPathForDirectoriesInDomains(NSMusicDirectory, NSUserDomainMask, YES) lastObject];
|
||||
return pathEscape(path);
|
||||
}
|
||||
|
||||
static NSURL *defaultDownloadsDirectory(void) {
|
||||
return [[NSFileManager defaultManager] URLForDirectory:NSDownloadsDirectory
|
||||
inDomain:NSUserDomainMask
|
||||
appropriateForURL:nil
|
||||
create:NO
|
||||
error:nil];
|
||||
NSString *path = [NSSearchPathForDirectoriesInDomains(NSDownloadsDirectory, NSUserDomainMask, YES) lastObject];
|
||||
return pathEscape(path);
|
||||
}
|
||||
|
||||
static NSURL *defaultMoviesDirectory(void) {
|
||||
return [[NSFileManager defaultManager] URLForDirectory:NSMoviesDirectory
|
||||
inDomain:NSUserDomainMask
|
||||
appropriateForURL:nil
|
||||
create:NO
|
||||
error:nil];
|
||||
NSString *path = [NSSearchPathForDirectoriesInDomains(NSMoviesDirectory, NSUserDomainMask, YES) lastObject];
|
||||
return pathEscape(path);
|
||||
}
|
||||
|
||||
@interface PathItem : NSObject
|
||||
|
|
Loading…
Reference in New Issue