#pragma once #include #include #include namespace XCEngine::UI::Editor::Support { inline std::filesystem::path GetExecutableDirectory() { std::vector buffer(MAX_PATH); while (true) { const DWORD copied = ::GetModuleFileNameW( nullptr, buffer.data(), static_cast(buffer.size())); if (copied == 0u) { return std::filesystem::current_path().lexically_normal(); } if (copied < buffer.size() - 1u) { return std::filesystem::path(std::wstring(buffer.data(), copied)) .parent_path() .lexically_normal(); } buffer.resize(buffer.size() * 2u); } } } // namespace XCEngine::UI::Editor::Support