Skip to content

Commit

Permalink
LoggedFstream: Fix OpenFile error check
Browse files Browse the repository at this point in the history
Fixes #6626
  • Loading branch information
glebm authored and AJenbo committed Nov 9, 2024
1 parent cce04b5 commit e010591
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
4 changes: 3 additions & 1 deletion Source/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,9 @@ std::vector<std::string> GetMPQSearchPaths()
}
#endif

paths.emplace_back(""); // PWD
if (paths.empty() || !paths.back().empty()) {
paths.emplace_back(); // PWD
}

if (SDL_LOG_PRIORITY_VERBOSE >= SDL_LogGetPriority(SDL_LOG_CATEGORY_APPLICATION)) {
LogVerbose("Paths:\n base: {}\n pref: {}\n config: {}\n assets: {}",
Expand Down
4 changes: 2 additions & 2 deletions Source/utils/file_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ bool FileExists(const char *path)
::SetLastError(ERROR_SUCCESS);
} else {
#if defined(NXDK)
LogError("GetFileAttributesA: error code {}", ::GetLastError());
LogError("GetFileAttributesA({}): error code {}", path, ::GetLastError());
#else
LogError("PathFileExistsW: error code {}", ::GetLastError());
LogError("PathFileExistsW({}): error code {}", path, ::GetLastError());
#endif
}
return false;
Expand Down
2 changes: 1 addition & 1 deletion Source/utils/logged_fstream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ struct LoggedFStream {
bool Open(const char *path, const char *mode)
{
s_ = OpenFile(path, mode);
return CheckError("fopen(\"{}\", \"{}\")", path, mode);
return CheckError(s_ != nullptr, "fopen(\"{}\", \"{}\")", path, mode);
}

void Close()
Expand Down

0 comments on commit e010591

Please sign in to comment.