mirror of
https://github.com/citra-emu/citra.git
synced 2024-12-27 05:00:06 +00:00
core\file_sys\archive_sdmc.cpp: Log error message if file failed to open. (#6284)
This commit is contained in:
parent
68162c29b4
commit
5215468ff6
@ -16,16 +16,19 @@
|
|||||||
// Call directly after the command or use the error num.
|
// Call directly after the command or use the error num.
|
||||||
// This function might change the error code.
|
// This function might change the error code.
|
||||||
std::string GetLastErrorMsg() {
|
std::string GetLastErrorMsg() {
|
||||||
static const std::size_t buff_size = 255;
|
constexpr std::size_t buff_size = 255;
|
||||||
char err_str[buff_size];
|
char err_str[buff_size];
|
||||||
|
std::size_t msg_len;
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, nullptr, GetLastError(),
|
msg_len =
|
||||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), err_str, buff_size, nullptr);
|
FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, nullptr, GetLastError(),
|
||||||
|
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), err_str, buff_size, nullptr);
|
||||||
#else
|
#else
|
||||||
// Thread safe (XSI-compliant)
|
// Thread safe (XSI-compliant)
|
||||||
strerror_r(errno, err_str, buff_size);
|
strerror_r(errno, err_str, buff_size);
|
||||||
|
msg_len = strnlen(err_str, buff_size);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return std::string(err_str, buff_size);
|
return std::string(err_str, msg_len);
|
||||||
}
|
}
|
||||||
|
@ -106,7 +106,7 @@ ResultVal<std::unique_ptr<FileBackend>> SDMCArchive::OpenFileBase(const Path& pa
|
|||||||
|
|
||||||
FileUtil::IOFile file(full_path, mode.write_flag ? "r+b" : "rb");
|
FileUtil::IOFile file(full_path, mode.write_flag ? "r+b" : "rb");
|
||||||
if (!file.IsOpen()) {
|
if (!file.IsOpen()) {
|
||||||
LOG_CRITICAL(Service_FS, "(unreachable) Unknown error opening {}", full_path);
|
LOG_CRITICAL(Service_FS, "Error opening {}: {}", full_path, GetLastErrorMsg());
|
||||||
return ERROR_NOT_FOUND;
|
return ERROR_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user