aboutsummaryrefslogtreecommitdiff
path: root/src/common/io/Resource.cpp
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2022-01-25 18:39:14 +0800
committercrupest <crupest@outlook.com>2022-01-25 18:39:14 +0800
commitd3aa43d9ea0dfc32935767cf60a89af2736dc339 (patch)
treee8cf043ac6d9a2e6ce038ad6b1f57079834ef129 /src/common/io/Resource.cpp
parent71c01a175a939d1a519ab235fdfdeec1101f8b84 (diff)
downloadcru-d3aa43d9ea0dfc32935767cf60a89af2736dc339.tar.gz
cru-d3aa43d9ea0dfc32935767cf60a89af2736dc339.tar.bz2
cru-d3aa43d9ea0dfc32935767cf60a89af2736dc339.zip
...
Diffstat (limited to 'src/common/io/Resource.cpp')
-rw-r--r--src/common/io/Resource.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/common/io/Resource.cpp b/src/common/io/Resource.cpp
index e2ff8004..da16b578 100644
--- a/src/common/io/Resource.cpp
+++ b/src/common/io/Resource.cpp
@@ -7,10 +7,19 @@
#endif
namespace cru::io {
-std::unique_ptr<Stream> CreateStreamFromResourcePath(const String& path) {
+std::filesystem::path GetResourceDir() {
#if defined(CRU_PLATFORM_OSX)
- // CFBundleRef main_bundle = CFBundleGetMainBundle();
- throw Exception(u"Not implemented.");
+ CFBundleRef main_bundle = CFBundleGetMainBundle();
+ CFURLRef bundle_url = CFBundleCopyBundleURL(main_bundle);
+ CFStringRef cf_string_ref =
+ CFURLCopyFileSystemPath(bundle_url, kCFURLPOSIXPathStyle);
+ std::filesystem::path bundle_path(
+ CFStringGetCStringPtr(cf_string_ref, kCFStringEncodingUTF8));
+
+ CFRelease(bundle_url);
+ CFRelease(cf_string_ref);
+
+ return bundle_path / "Contents/Resources";
#elif defined(CRU_PLATFORM_WINDOWS)
throw Exception(u"Not implemented.");
#else