mirror of
https://github.com/zydeco/minivmac4ios.git
synced 2024-11-26 00:49:20 +00:00
use ~/Documents/Mini vMac when not sandboxed
This commit is contained in:
parent
aae7b67945
commit
671edf8bc0
@ -17,6 +17,7 @@ extern NSString * const MNVMDidEjectDiskNotification;
|
|||||||
@property (assign, nonatomic, getter=isEmulatorRunning) BOOL emulatorRunning;
|
@property (assign, nonatomic, getter=isEmulatorRunning) BOOL emulatorRunning;
|
||||||
@property (nonatomic, readonly) NSString *documentsPath;
|
@property (nonatomic, readonly) NSString *documentsPath;
|
||||||
@property (nonatomic, readonly) NSArray<NSString*> *diskImageExtensions;
|
@property (nonatomic, readonly) NSArray<NSString*> *diskImageExtensions;
|
||||||
|
@property (readonly, nonatomic, getter = isSandboxed) BOOL sandboxed;
|
||||||
|
|
||||||
+ (instancetype)sharedInstance;
|
+ (instancetype)sharedInstance;
|
||||||
- (void)showAlertWithTitle:(NSString *)title message:(NSString *)message;
|
- (void)showAlertWithTitle:(NSString *)title message:(NSString *)message;
|
||||||
|
@ -199,6 +199,16 @@ NSString * const MNVMDidEjectDiskNotification = @"MNVMDidEjectDisk";
|
|||||||
|
|
||||||
#pragma mark - Files
|
#pragma mark - Files
|
||||||
|
|
||||||
|
- (BOOL)isSandboxed {
|
||||||
|
static dispatch_once_t onceToken;
|
||||||
|
static BOOL sandboxed;
|
||||||
|
dispatch_once(&onceToken, ^{
|
||||||
|
NSString *bundlePath = [[NSBundle mainBundle] bundlePath];
|
||||||
|
sandboxed = ![bundlePath hasPrefix:@"/Applications/"];
|
||||||
|
});
|
||||||
|
return sandboxed;
|
||||||
|
}
|
||||||
|
|
||||||
- (NSArray<NSString *> *)diskImageExtensions {
|
- (NSArray<NSString *> *)diskImageExtensions {
|
||||||
return @[@"dsk", @"img", @"dc42", @"diskcopy42"];
|
return @[@"dsk", @"img", @"dc42", @"diskcopy42"];
|
||||||
}
|
}
|
||||||
@ -208,6 +218,10 @@ NSString * const MNVMDidEjectDiskNotification = @"MNVMDidEjectDisk";
|
|||||||
static NSString *documentsPath;
|
static NSString *documentsPath;
|
||||||
dispatch_once(&onceToken, ^{
|
dispatch_once(&onceToken, ^{
|
||||||
documentsPath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES).firstObject.stringByStandardizingPath;
|
documentsPath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES).firstObject.stringByStandardizingPath;
|
||||||
|
if (!self.sandboxed) {
|
||||||
|
documentsPath = [documentsPath stringByAppendingPathComponent:@"Mini vMac"].stringByStandardizingPath;
|
||||||
|
}
|
||||||
|
[[NSFileManager defaultManager] createDirectoryAtPath:documentsPath withIntermediateDirectories:YES attributes:nil error:NULL];
|
||||||
[[NSFileManager defaultManager] createDirectoryAtPath:documentsPath withIntermediateDirectories:YES attributes:nil error:NULL];
|
[[NSFileManager defaultManager] createDirectoryAtPath:documentsPath withIntermediateDirectories:YES attributes:nil error:NULL];
|
||||||
});
|
});
|
||||||
return documentsPath;
|
return documentsPath;
|
||||||
|
Loading…
Reference in New Issue
Block a user