Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions Code/core/src/Filesystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,23 @@ namespace TiltedPhoques
{
std::filesystem::path GetPath() noexcept
{
#if TP_PLATFORM_WINDOWS
WCHAR dllPath[MAX_PATH] = { 0 };
GetModuleFileNameW(reinterpret_cast<HINSTANCE>(&__ImageBase), dllPath, std::size(dllPath));
static std::once_flag bInitialized;
static std::filesystem::path currentPath;

std::error_code ec;
const auto currentPath = std::filesystem::path(dllPath).parent_path();
std::call_once(bInitialized, []
{
#if TP_PLATFORM_WINDOWS
WCHAR dllPath[MAX_PATH] = { 0 };
GetModuleFileNameW(nullptr, dllPath, std::size(dllPath));

return currentPath;
std::error_code ec;
currentPath = std::filesystem::path(dllPath).parent_path();
#else
return std::filesystem::current_path();
currentPath = std::filesystem::current_path();
#endif
});

return currentPath;
}

String LoadFile(const std::filesystem::path& acPath) noexcept
Expand Down