2021-03-01 07:56:49 +00: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 18:09:36 +00:00
|
|
|
result = [appSupportDir URLByAppendingPathComponent:@"imhex/patterns"];
|
2021-03-01 07:56:49 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ImHexPath::PatternsInclude:
|
2021-06-18 18:09:36 +00:00
|
|
|
result = [appSupportDir URLByAppendingPathComponent:@"imhex/patterns"];
|
2021-03-01 07:56:49 +00:00
|
|
|
break;
|
|
|
|
case ImHexPath::Magic:
|
2021-06-18 18:09:36 +00:00
|
|
|
result = [appSupportDir URLByAppendingPathComponent:@"imhex/magic"];
|
2021-03-01 07:56:49 +00:00
|
|
|
break;
|
|
|
|
case ImHexPath::Python:
|
2021-06-18 18:09:36 +00:00
|
|
|
result = [appSupportDir URLByAppendingPathComponent:@"imhex"];
|
2021-03-01 07:56:49 +00:00
|
|
|
break;
|
|
|
|
case ImHexPath::Plugins:
|
2021-06-18 18:09:36 +00:00
|
|
|
result = [appSupportDir URLByAppendingPathComponent:@"imhex/plugins"];
|
2021-03-01 07:56:49 +00:00
|
|
|
break;
|
|
|
|
case ImHexPath::Yara:
|
2021-06-18 18:09:36 +00:00
|
|
|
result = [appSupportDir URLByAppendingPathComponent:@"imhex/yara"];
|
2021-03-01 07:56:49 +00:00
|
|
|
break;
|
|
|
|
case ImHexPath::Config:
|
2021-06-18 18:09:36 +00:00
|
|
|
result = [appSupportDir URLByAppendingPathComponent:@"imhex/config"];
|
2021-03-01 07:56:49 +00:00
|
|
|
break;
|
|
|
|
case ImHexPath::Resources:
|
2021-06-18 18:09:36 +00:00
|
|
|
result = [appSupportDir URLByAppendingPathComponent:@"imhex/resources"];
|
2021-03-01 07:56:49 +00:00
|
|
|
break;
|
2021-06-25 23:18:33 +00:00
|
|
|
case ImHexPath::Constants:
|
|
|
|
result = [appSupportDir URLByAppendingPathComponent:@"imhex/constants"];
|
|
|
|
break;
|
2021-03-01 07:56:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (result == nil) {
|
|
|
|
__builtin_unreachable();
|
|
|
|
}
|
|
|
|
|
|
|
|
return std::string([[result path] UTF8String]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|