aboutsummaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/common')
-rw-r--r--src/common/String.cpp4
-rw-r--r--src/common/io/Resource.cpp15
2 files changed, 16 insertions, 3 deletions
diff --git a/src/common/String.cpp b/src/common/String.cpp
index 62943059..e791d119 100644
--- a/src/common/String.cpp
+++ b/src/common/String.cpp
@@ -33,6 +33,10 @@ String String::FromUtf8(const char* str, Index size) {
return result;
}
+String String::FromStdPath(const std::filesystem::path& path) {
+ return String::FromUtf8(path.string());
+}
+
char16_t String::kEmptyBuffer[1] = {0};
String::String(const_pointer str) : String(str, GetStrSize(str)) {}
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