diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/base/io/Resource.cpp | 22 | ||||
-rw-r--r-- | src/platform/gui/xcb/Window.cpp | 1 |
2 files changed, 16 insertions, 7 deletions
diff --git a/src/base/io/Resource.cpp b/src/base/io/Resource.cpp index d369b5f5..e599f8a9 100644 --- a/src/base/io/Resource.cpp +++ b/src/base/io/Resource.cpp @@ -1,19 +1,20 @@ #include "cru/base/io/Resource.h" +#include "cru/base/Base.h" #include "cru/base/Exception.h" -#include "cru/base/log/Logger.h" #if defined(CRU_PLATFORM_OSX) #include <CoreFoundation/CoreFoundation.h> #elif defined(CRU_PLATFORM_WINDOWS) #include <Windows.h> +#elif defined(__linux) +#include <fstream> +#include <sstream> #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); @@ -26,10 +27,18 @@ std::filesystem::path GetResourceDir() { CFRelease(cf_string_ref); return bundle_path / "Contents/Resources"; -#elif defined(CRU_PLATFORM_WINDOWS) +#elif defined(_WIN32) || defined(__linux) +#if defined(_WIN32) wchar_t buffer[MAX_PATH]; DWORD size = ::GetModuleFileNameW(nullptr, buffer, MAX_PATH); std::filesystem::path module_path(buffer, buffer + size); +#else // linux + std::ifstream file("/proc/self/cmdline"); + std::stringstream buffer; + buffer << file.rdbuf(); + auto str = buffer.str(); + std::filesystem::path module_path(str.substr(0, str.find('\0'))); +#endif auto p = module_path; while (p.has_parent_path()) { p = p.parent_path(); @@ -41,8 +50,9 @@ std::filesystem::path GetResourceDir() { } throw Exception(u"Failed to find resource directory."); -#else - throw Exception(u"Not implemented."); + #endif + + NotImplemented(); } } // namespace cru::io diff --git a/src/platform/gui/xcb/Window.cpp b/src/platform/gui/xcb/Window.cpp index 63ea68b1..667edadc 100644 --- a/src/platform/gui/xcb/Window.cpp +++ b/src/platform/gui/xcb/Window.cpp @@ -142,7 +142,6 @@ void XcbWindow::SetVisibility(WindowVisibilityType visibility) { auto old_value = static_cast<std::uint32_t *>( XcbGetProperty(*xcb_window_, atom, atom, 0, 2)); if (old_value) value[1] = old_value[1]; - UnreachableCode(); xcb_change_property(application_->GetXcbConnection(), XCB_PROP_MODE_REPLACE, window, atom, atom, 32, sizeof(value) / sizeof(*value), |