From a07d588c94f68cdc559ceb016c031c9199f0b868 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Sun, 20 Mar 2022 11:52:09 -0400 Subject: we can now build a mac bundle! --- src/runtime_macos.mm | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 src/runtime_macos.mm (limited to 'src/runtime_macos.mm') 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 @@ +#include "runtime.h" +#import + +std::string Runtime::getResourcePath(std::string_view filename) { + CFStringRef fileNameRef = CFStringCreateWithCString(kCFAllocatorDefault, filename.data(), kCFStringEncodingUTF8); + CFURLRef appUrlRef = CFBundleCopyResourceURL(CFBundleGetMainBundle(), fileNameRef, NULL, NULL); + CFStringRef filePathRef = CFURLCopyPath(appUrlRef); + const char* filePath = CFStringGetCStringPtr(filePathRef, kCFStringEncodingUTF8); + std::string result(filePath); + + CFRelease(filePathRef); + CFRelease(appUrlRef); + CFRelease(fileNameRef); + + return result; +} -- cgit 1.4.1