Skip to content

Commit 5133d5b

Browse files
authored
Merge pull request #18 from cortex-command-community/early-return-get-full-path
Early return when full path exists on Linux
2 parents 40a2ec0 + e031fb9 commit 5133d5b

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

Source/Managers/LuaMan.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1043,6 +1043,10 @@ namespace RTE {
10431043
FILE *file = fopen(fullPath.c_str(), accessMode.c_str());
10441044
#else
10451045
FILE *file = [&fullPath, &accessMode]() -> FILE* {
1046+
if (std::filesystem::exists(fullPath)) {
1047+
return fopen(fullPath.c_str(), accessMode.c_str());
1048+
}
1049+
10461050
std::filesystem::path inspectedPath = System::GetWorkingDirectory();
10471051
const std::filesystem::path relativeFilePath = std::filesystem::path(fullPath).lexically_relative(inspectedPath);
10481052

Source/System/RTETools.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,10 @@ namespace RTE {
222222
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
223223

224224
std::string GetCaseInsensitiveFullPath(const std::string &fullPath) {
225+
if (std::filesystem::exists(fullPath)) {
226+
return fullPath;
227+
}
228+
225229
std::filesystem::path inspectedPath = System::GetWorkingDirectory();
226230
const std::filesystem::path relativeFilePath = std::filesystem::path(fullPath).lexically_relative(inspectedPath);
227231

0 commit comments

Comments
 (0)