2022-06-25 12:19:59 +02:00
|
|
|
#if defined(OS_MACOS)
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <Foundation/Foundation.h>
|
|
|
|
|
2023-01-04 14:24:07 +01:00
|
|
|
char* getMacExecutableDirectoryPath(void) {
|
2022-06-25 12:19:59 +02:00
|
|
|
@autoreleasepool {
|
|
|
|
const char *pathString = [[[[[NSBundle mainBundle] executableURL] URLByDeletingLastPathComponent] path] UTF8String];
|
|
|
|
|
|
|
|
char *result = malloc(strlen(pathString) + 1);
|
|
|
|
strcpy(result, pathString);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-04 14:24:07 +01:00
|
|
|
char* getMacApplicationSupportDirectoryPath(void) {
|
2022-06-25 12:19:59 +02:00
|
|
|
@autoreleasepool {
|
|
|
|
NSError* error = nil;
|
|
|
|
NSURL* dirUrl = [[NSFileManager defaultManager] URLForDirectory:NSApplicationSupportDirectory
|
|
|
|
inDomain:NSUserDomainMask
|
|
|
|
appropriateForURL:nil
|
|
|
|
create:YES
|
|
|
|
error:&error];
|
|
|
|
|
|
|
|
if (error != nil) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *pathString = [[[dirUrl URLByAppendingPathComponent:(@"imhex")] path] UTF8String];
|
|
|
|
|
|
|
|
char *result = malloc(strlen(pathString) + 1);
|
|
|
|
strcpy(result, pathString);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void macFree(void *ptr) {
|
|
|
|
free(ptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|