summary refs log tree commit diff stats
path: root/src/runtime_macos.mm
diff options
context:
space:
mode:
Diffstat (limited to 'src/runtime_macos.mm')
-rw-r--r--src/runtime_macos.mm16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/runtime_macos.mm b/src/runtime_macos.mm new file mode 100644 index 0000000..b46e6f8 --- /dev/null +++ b/src/runtime_macos.mm
@@ -0,0 +1,16 @@
1#include "runtime.h"
2#import <Foundation/Foundation.h>
3
4std::string Runtime::getResourcePath(std::string_view filename) {
5 CFStringRef fileNameRef = CFStringCreateWithCString(kCFAllocatorDefault, filename.data(), kCFStringEncodingUTF8);
6 CFURLRef appUrlRef = CFBundleCopyResourceURL(CFBundleGetMainBundle(), fileNameRef, NULL, NULL);
7 CFStringRef filePathRef = CFURLCopyPath(appUrlRef);
8 const char* filePath = CFStringGetCStringPtr(filePathRef, kCFStringEncodingUTF8);
9 std::string result(filePath);
10
11 CFRelease(filePathRef);
12 CFRelease(appUrlRef);
13 CFRelease(fileNameRef);
14
15 return result;
16}