Browse Source

`LoggedFstream`: Fix `OpenFile` error check

Fixes #6626
pull/5866/head
Gleb Mazovetskiy 3 years ago
parent
commit
c7fefd74b6
  1. 4
      Source/init.cpp
  2. 4
      Source/utils/file_util.cpp
  3. 2
      Source/utils/logged_fstream.hpp

4
Source/init.cpp

@ -156,7 +156,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: {}",

4
Source/utils/file_util.cpp

@ -94,9 +94,9 @@ bool FileExists(const char *path)
::SetLastError(ERROR_SUCCESS);
} else {
#ifdef DEVILUTIONX_WINDOWS_NO_WCHAR
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;

2
Source/utils/logged_fstream.hpp

@ -16,7 +16,7 @@ public:
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()

Loading…
Cancel
Save