diff --git a/include/Nazara/Core/Error.hpp b/include/Nazara/Core/Error.hpp index c9b201417..bf2992438 100644 --- a/include/Nazara/Core/Error.hpp +++ b/include/Nazara/Core/Error.hpp @@ -38,7 +38,7 @@ namespace Nz static ErrorModeFlags ApplyFlags(ErrorModeFlags orFlags, ErrorModeFlags andFlags); - static constexpr std::string_view GetCurrentFileRelativeToEngine(std::string_view file); + static constexpr std::string_view TranslateFilepath(std::string_view file); static ErrorModeFlags GetFlags(); static std::string GetLastError(std::string_view* file = nullptr, unsigned int* line = nullptr, std::string_view* function = nullptr); static unsigned int GetLastSystemErrorCode(); diff --git a/include/Nazara/Core/Error.inl b/include/Nazara/Core/Error.inl index f7e90234f..80d539d92 100644 --- a/include/Nazara/Core/Error.inl +++ b/include/Nazara/Core/Error.inl @@ -4,12 +4,12 @@ namespace Nz { - constexpr std::string_view Error::GetCurrentFileRelativeToEngine(std::string_view file) + constexpr std::string_view Error::TranslateFilepath(std::string_view file) { - if (std::size_t offset = file.find("NazaraEngine/"); offset != file.npos) + if (std::size_t offset = file.rfind('/'); offset != file.npos) return file.substr(offset); - if (std::size_t offset = file.find("NazaraEngine\\"); offset != file.npos) + if (std::size_t offset = file.rfind('\\'); offset != file.npos) return file.substr(offset); return file; @@ -22,6 +22,6 @@ namespace Nz inline void Error::Trigger(ErrorType type, unsigned int line, std::string_view file, std::string_view function, std::string error) { - return TriggerInternal(type, std::move(error), line, GetCurrentFileRelativeToEngine(file), function); + return TriggerInternal(type, std::move(error), line, TranslateFilepath(file), function); } }