Files
86Box/src/unix/macOSXGlue.m

47 lines
1.6 KiB
Mathematica
Raw Normal View History

2021-11-18 18:04:56 +01:00
//
// macOSXGlue.m
// 86BOx MacoSx Glue....
// Todo: so much
// Created by Jerome Vernet on 18/11/2021.
// Copyright © 2021 Jerome Vernet. All rights reserved.
//
#import <Foundation/Foundation.h>
2022-11-19 08:49:04 -05:00
void
getDefaultROMPath(char *Path)
2021-11-18 18:04:56 +01:00
{
2022-11-19 08:49:04 -05:00
NSFileManager *sharedFM = [NSFileManager defaultManager];
NSArray *possibleURLs = [sharedFM URLsForDirectory:NSApplicationSupportDirectory
inDomains:NSUserDomainMask];
NSURL *appSupportDir = nil;
NSURL *appDirectory = nil;
2022-11-19 08:49:04 -05:00
if ([possibleURLs count] >= 1) {
// Use the first directory (if multiple are returned)
appSupportDir = [possibleURLs objectAtIndex:0];
}
2022-11-19 08:49:04 -05:00
// If a valid app support directory exists, add the
// app's bundle ID to it to specify the final directory.
if (appSupportDir) {
NSString *appBundleID = [[NSBundle mainBundle] bundleIdentifier];
appDirectory = [appSupportDir URLByAppendingPathComponent:appBundleID];
appDirectory = [appDirectory URLByAppendingPathComponent:@"roms"];
}
2021-11-18 18:04:56 +01:00
// create ~/Library/Application Support/... stuff
2022-11-19 08:49:04 -05:00
NSError *theError = nil;
if (![sharedFM createDirectoryAtURL:appDirectory
withIntermediateDirectories:YES
attributes:nil
error:&theError]) {
// Handle the error.
NSLog(@"Error creating user library rom path");
} else
NSLog(@"Create user rom path sucessfull");
2022-11-19 08:49:04 -05:00
strcpy(Path, [appDirectory fileSystemRepresentation]);
// return appDirectory;
2021-11-18 18:04:56 +01:00
}