diff --git a/src/common/io_file.h b/src/common/io_file.h index 177bddbad..8fed4981f 100644 --- a/src/common/io_file.h +++ b/src/common/io_file.h @@ -205,9 +205,9 @@ public: return WriteSpan(string); } - static void WriteBytes(const std::filesystem::path path, std::span data) { + static size_t WriteBytes(const std::filesystem::path path, std::span data) { IOFile out(path, FileAccessMode::Write); - out.Write(data); + return out.Write(data); } private: diff --git a/src/core/file_format/trp.cpp b/src/core/file_format/trp.cpp index 9c53c8588..17eea9f36 100644 --- a/src/core/file_format/trp.cpp +++ b/src/core/file_format/trp.cpp @@ -12,6 +12,7 @@ void TRP::GetNPcommID(const std::filesystem::path& trophyPath, int index) { std::filesystem::path trpPath = trophyPath / "sce_sys/npbind.dat"; Common::FS::IOFile npbindFile(trpPath, Common::FS::FileAccessMode::Read); if (!npbindFile.IsOpen()) { + LOG_CRITICAL(Common_Filesystem, "Failed to open npbind.dat file"); return; } if (!npbindFile.Seek(0x84 + (index * 0x180))) { @@ -36,6 +37,7 @@ bool TRP::Extract(const std::filesystem::path& trophyPath) { std::filesystem::path title = trophyPath.filename(); std::filesystem::path gameSysDir = trophyPath / "sce_sys/trophy/"; if (!std::filesystem::exists(gameSysDir)) { + LOG_CRITICAL(Common_Filesystem, "Game sce_sys directory doesn't exist"); return false; } for (int index = 0; const auto& it : std::filesystem::directory_iterator(gameSysDir)) { @@ -44,13 +46,16 @@ bool TRP::Extract(const std::filesystem::path& trophyPath) { Common::FS::IOFile file(it.path(), Common::FS::FileAccessMode::Read); if (!file.IsOpen()) { + LOG_CRITICAL(Common_Filesystem, "Unable to open trophy file for read"); return false; } TrpHeader header; file.Read(header); - if (header.magic != 0xDCA24D00) + if (header.magic != 0xDCA24D00) { + LOG_CRITICAL(Common_Filesystem, "Wrong trophy magic number"); return false; + } s64 seekPos = sizeof(TrpHeader); std::filesystem::path trpFilesPath( @@ -99,7 +104,13 @@ bool TRP::Extract(const std::filesystem::path& trophyPath) { size_t pos = xml_name.find("ESFM"); if (pos != std::string::npos) xml_name.replace(pos, xml_name.length(), "XML"); - Common::FS::IOFile::WriteBytes(trpFilesPath / "Xml" / xml_name, XML); + size_t written = + Common::FS::IOFile::WriteBytes(trpFilesPath / "Xml" / xml_name, XML); + if (written != XML.size()) { + LOG_CRITICAL(Common_Filesystem, + "Trophy XML write failed, wanted to write {} bytes, wrote {}", + XML.size(), written); + } } } }