[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;
|
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) {
|
static NSURL *defaultMusicDirectory(void) {
|
||||||
return [[NSFileManager defaultManager] URLForDirectory:NSMusicDirectory
|
NSString *path = [NSSearchPathForDirectoriesInDomains(NSMusicDirectory, NSUserDomainMask, YES) lastObject];
|
||||||
inDomain:NSUserDomainMask
|
return pathEscape(path);
|
||||||
appropriateForURL:nil
|
|
||||||
create:NO
|
|
||||||
error:nil];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@interface FileTreeDataSource ()
|
@interface FileTreeDataSource ()
|
||||||
|
|
|
@ -18,28 +18,28 @@
|
||||||
@property(nonatomic) NSURL *_Nullable url;
|
@property(nonatomic) NSURL *_Nullable url;
|
||||||
@end
|
@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) {
|
static NSURL *defaultMusicDirectory(void) {
|
||||||
return [[NSFileManager defaultManager] URLForDirectory:NSMusicDirectory
|
NSString *path = [NSSearchPathForDirectoriesInDomains(NSMusicDirectory, NSUserDomainMask, YES) lastObject];
|
||||||
inDomain:NSUserDomainMask
|
return pathEscape(path);
|
||||||
appropriateForURL:nil
|
|
||||||
create:NO
|
|
||||||
error:nil];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static NSURL *defaultDownloadsDirectory(void) {
|
static NSURL *defaultDownloadsDirectory(void) {
|
||||||
return [[NSFileManager defaultManager] URLForDirectory:NSDownloadsDirectory
|
NSString *path = [NSSearchPathForDirectoriesInDomains(NSDownloadsDirectory, NSUserDomainMask, YES) lastObject];
|
||||||
inDomain:NSUserDomainMask
|
return pathEscape(path);
|
||||||
appropriateForURL:nil
|
|
||||||
create:NO
|
|
||||||
error:nil];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static NSURL *defaultMoviesDirectory(void) {
|
static NSURL *defaultMoviesDirectory(void) {
|
||||||
return [[NSFileManager defaultManager] URLForDirectory:NSMoviesDirectory
|
NSString *path = [NSSearchPathForDirectoriesInDomains(NSMoviesDirectory, NSUserDomainMask, YES) lastObject];
|
||||||
inDomain:NSUserDomainMask
|
return pathEscape(path);
|
||||||
appropriateForURL:nil
|
|
||||||
create:NO
|
|
||||||
error:nil];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@interface PathItem : NSObject
|
@interface PathItem : NSObject
|
||||||
|
|
Loading…
Reference in New Issue