2021-03-01 08:56:49 +01:00
|
|
|
#if defined(OS_MACOS)
|
|
|
|
#include <hex/helpers/utils_mac.h>
|
|
|
|
|
|
|
|
#include <Foundation/Foundation.h>
|
|
|
|
|
|
|
|
namespace hex {
|
|
|
|
std::string getPathForMac(ImHexPath path) {
|
|
|
|
@autoreleasepool {
|
|
|
|
NSError * error = nil;
|
|
|
|
NSURL * appSupportDir = [[NSFileManager defaultManager] URLForDirectory:NSApplicationSupportDirectory
|
|
|
|
inDomain:NSUserDomainMask
|
|
|
|
appropriateForURL:nil
|
|
|
|
create:YES
|
|
|
|
error:&error];
|
|
|
|
if (error != nil) {
|
|
|
|
__builtin_unreachable();
|
|
|
|
}
|
|
|
|
|
|
|
|
NSURL * result = nil;
|
|
|
|
switch (path) {
|
|
|
|
case ImHexPath::Patterns:
|
2021-06-18 20:09:36 +02:00
|
|
|
result = [appSupportDir URLByAppendingPathComponent:@"imhex/patterns"];
|
2021-03-01 08:56:49 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ImHexPath::PatternsInclude:
|
2021-06-18 20:09:36 +02:00
|
|
|
result = [appSupportDir URLByAppendingPathComponent:@"imhex/patterns"];
|
2021-03-01 08:56:49 +01:00
|
|
|
break;
|
|
|
|
case ImHexPath::Magic:
|
2021-06-18 20:09:36 +02:00
|
|
|
result = [appSupportDir URLByAppendingPathComponent:@"imhex/magic"];
|
2021-03-01 08:56:49 +01:00
|
|
|
break;
|
|
|
|
case ImHexPath::Python:
|
2021-06-18 20:09:36 +02:00
|
|
|
result = [appSupportDir URLByAppendingPathComponent:@"imhex"];
|
2021-03-01 08:56:49 +01:00
|
|
|
break;
|
|
|
|
case ImHexPath::Plugins:
|
2021-06-18 20:09:36 +02:00
|
|
|
result = [appSupportDir URLByAppendingPathComponent:@"imhex/plugins"];
|
2021-03-01 08:56:49 +01:00
|
|
|
break;
|
|
|
|
case ImHexPath::Yara:
|
2021-06-18 20:09:36 +02:00
|
|
|
result = [appSupportDir URLByAppendingPathComponent:@"imhex/yara"];
|
2021-03-01 08:56:49 +01:00
|
|
|
break;
|
|
|
|
case ImHexPath::Config:
|
2021-06-18 20:09:36 +02:00
|
|
|
result = [appSupportDir URLByAppendingPathComponent:@"imhex/config"];
|
2021-03-01 08:56:49 +01:00
|
|
|
break;
|
|
|
|
case ImHexPath::Resources:
|
2021-06-18 20:09:36 +02:00
|
|
|
result = [appSupportDir URLByAppendingPathComponent:@"imhex/resources"];
|
2021-03-01 08:56:49 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (result == nil) {
|
|
|
|
__builtin_unreachable();
|
|
|
|
}
|
|
|
|
|
|
|
|
return std::string([[result path] UTF8String]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|