diff --git a/rpcs3/Crypto/unedat.cpp b/rpcs3/Crypto/unedat.cpp index e92a5d69e9..e6b25f5c37 100644 --- a/rpcs3/Crypto/unedat.cpp +++ b/rpcs3/Crypto/unedat.cpp @@ -936,7 +936,7 @@ bool EDATADecrypter::ReadHeader() // Try decrypting the first block instead u8 data_sample[1]; - if (!ReadData(0, data_sample, 1)) + if (file_size && !ReadData(0, data_sample, 1)) { return false; } diff --git a/rpcs3/Emu/Cell/lv2/sys_fs.cpp b/rpcs3/Emu/Cell/lv2/sys_fs.cpp index 7fadd9cb40..2794e31483 100644 --- a/rpcs3/Emu/Cell/lv2/sys_fs.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_fs.cpp @@ -51,16 +51,15 @@ void fmt_class_string::format(std::string& out, u64 arg) return "N/A"; } - std::string size_str = fmt::format("0x%05x ", size); + std::string size_str; switch (std::bit_width(size) / 10 * 10) { - case 64: size_str = "0"s; break; - case 0: fmt::append(size_str, "(%u)", size); break; - case 10: fmt::append(size_str, "(%gKB)", size / 1024.); break; - case 20: fmt::append(size_str, "(%gMB)", size / (1024. * 1024)); break; + case 0: fmt::append(size_str, "%u", size); break; + case 10: fmt::append(size_str, "%gKB", size / 1024.); break; + case 20: fmt::append(size_str, "%gMB", size / (1024. * 1024)); break; default: - case 30: fmt::append(size_str, "(%gGB)", size / (1024. * 1024 * 1024)); break; + case 30: fmt::append(size_str, "%gGB", size / (1024. * 1024 * 1024)); break; } return size_str; @@ -69,7 +68,7 @@ void fmt_class_string::format(std::string& out, u64 arg) const usz pos = file.file ? file.file.pos() : umax; const usz size = file.file ? file.file.size() : umax; - fmt::append(out, u8"%s, ā€œ%sā€, Mode: 0x%x, Flags: 0x%x, Pos: %s, Size: %s", file.type, file.name.data(), file.mode, file.flags, get_size(pos), get_size(size)); + fmt::append(out, u8"%s, ā€œ%sā€, Mode: 0x%x, Flags: 0x%x, Pos/Size: %s/%s (0x%x/0x%x)", file.type, file.name.data(), file.mode, file.flags, get_size(pos), get_size(size), pos, size); } template<> @@ -616,25 +615,19 @@ error_code sys_fs_open(ppu_thread& ppu, vm::cptr path, s32 flags, vm::ptr< return {error, path}; } - if (type >= lv2_file_type::sdata) + if (const u32 id = idm::import([&ppath = ppath, &file = file, mode, flags, &real = real, &type = type]() -> std::shared_ptr { - sys_fs.warning("sys_fs_open(): NPDRM detected"); + std::shared_ptr result; - if (const u32 id = idm::import([&ppath = ppath, &file = file, mode, flags, &real = real, &type = type]() -> std::shared_ptr + if (type >= lv2_file_type::sdata && !g_fxo->get().npdrm_fds.try_inc(16)) { - if (!g_fxo->get().npdrm_fds.try_inc(16)) - { - return nullptr; - } - - return std::make_shared(ppath, std::move(file), mode, flags, real, type); - })) - { - *fd = id; - return CELL_OK; + return result; } - } - else if (const u32 id = idm::make(ppath, std::move(file), mode, flags, real)) + + result = std::make_shared(ppath, std::move(file), mode, flags, real, type); + sys_fs.warning("sys_fs_open(): fd=%u, %s", idm::last_id(), *result); + return result; + })) { *fd = id; return CELL_OK; @@ -839,7 +832,7 @@ error_code sys_fs_close(ppu_thread& ppu, u32 fd) return {CELL_EBADF, fd}; } - sys_fs.warning("sys_fs_close(fd=%u): path='%s'", fd, file->name.data()); + sys_fs.warning("sys_fs_close(fd=%u): %s", fd, *file); if (file->lock == 1) {