aboutsummaryrefslogtreecommitdiff
path: root/src/common/io/Resource.cpp
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2024-10-06 13:57:39 +0800
committercrupest <crupest@outlook.com>2024-10-06 13:57:39 +0800
commitdfe62dcf8bcefc523b466e127c3edc4dc2756629 (patch)
tree1c751a14ba0da07ca2ff805633f97568060aa4c9 /src/common/io/Resource.cpp
parentf51eb955e188858272230a990565931e7403f23b (diff)
downloadcru-dfe62dcf8bcefc523b466e127c3edc4dc2756629.tar.gz
cru-dfe62dcf8bcefc523b466e127c3edc4dc2756629.tar.bz2
cru-dfe62dcf8bcefc523b466e127c3edc4dc2756629.zip
Rename common to base.
Diffstat (limited to 'src/common/io/Resource.cpp')
-rw-r--r--src/common/io/Resource.cpp48
1 files changed, 0 insertions, 48 deletions
diff --git a/src/common/io/Resource.cpp b/src/common/io/Resource.cpp
deleted file mode 100644
index b847e1cf..00000000
--- a/src/common/io/Resource.cpp
+++ /dev/null
@@ -1,48 +0,0 @@
-#include "cru/common/io/Resource.h"
-#include "cru/common/Exception.h"
-#include "cru/common/log/Logger.h"
-
-#if defined(CRU_PLATFORM_OSX)
-#include <CoreFoundation/CoreFoundation.h>
-#elif defined(CRU_PLATFORM_WINDOWS)
-#include <Windows.h>
-#endif
-
-#include <filesystem>
-
-namespace cru::io {
-std::filesystem::path GetResourceDir() {
- constexpr auto kLogTag = u"GetResourceDir";
-
-#if defined(CRU_PLATFORM_OSX)
- 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)
- wchar_t buffer[MAX_PATH];
- DWORD size = ::GetModuleFileNameW(nullptr, buffer, MAX_PATH);
- std::filesystem::path module_path(buffer, buffer + size);
- auto p = module_path;
- while (p.has_parent_path()) {
- p = p.parent_path();
- auto resource_dir_path = p / "assets";
- if (std::filesystem::exists(resource_dir_path) &&
- std::filesystem::is_directory(resource_dir_path)) {
- return resource_dir_path;
- }
- }
-
- throw Exception(u"Failed to find resource directory.");
-#else
- throw Exception(u"Not implemented.");
-#endif
-}
-} // namespace cru::io