Some nits and fixes on paths (#1190)

* Some nits and fixes

* More path conversions

* Add some more logging

* Log the path too
This commit is contained in:
Paris Oplopoios 2024-10-02 07:18:00 +03:00 committed by GitHub
parent ee1e55d5e1
commit d20efcb0d2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 31 additions and 19 deletions

View file

@ -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))) {
@ -35,6 +36,7 @@ static void removePadding(std::vector<u8>& vec) {
bool TRP::Extract(const std::filesystem::path& trophyPath, const std::string titleId) {
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)) {
@ -43,13 +45,16 @@ bool TRP::Extract(const std::filesystem::path& trophyPath, const std::string tit
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(
@ -98,7 +103,14 @@ bool TRP::Extract(const std::filesystem::path& trophyPath, const std::string tit
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);
std::filesystem::path path = trpFilesPath / "Xml" / xml_name;
size_t written = Common::FS::IOFile::WriteBytes(path, XML);
if (written != XML.size()) {
LOG_CRITICAL(
Common_Filesystem,
"Trophy XML {} write failed, wanted to write {} bytes, wrote {}",
fmt::UTF(path.u8string()), XML.size(), written);
}
}
}
}