diff --git a/rpcs3/Emu/Cell/Modules/cellSaveData.cpp b/rpcs3/Emu/Cell/Modules/cellSaveData.cpp index 2f45e39e1b..5d8d70363b 100644 --- a/rpcs3/Emu/Cell/Modules/cellSaveData.cpp +++ b/rpcs3/Emu/Cell/Modules/cellSaveData.cpp @@ -498,9 +498,6 @@ static NEVER_INLINE s32 savedata_op(ppu_thread& ppu, u32 operation, u32 version, } statGet->bind = 0; - statGet->sizeKB = save_entry.size / 1024; - statGet->sysSizeKB = 0; // This is the size of system files, but PARAM.SFO is very small and PARAM.PDF is not used - statGet->fileNum = 0; statGet->fileList.set(setBuf->buf.addr()); statGet->fileListNum = 0; @@ -508,17 +505,37 @@ static NEVER_INLINE s32 savedata_op(ppu_thread& ppu, u32 operation, u32 version, auto file_list = statGet->fileList.get_ptr(); + u32 size_kbytes = 0; + for (auto&& entry : fs::dir(dir_path)) { entry.name = vfs::unescape(entry.name); // only files, system files ignored, fileNum is limited by setBuf->fileListMax - if (!entry.is_directory && entry.name != "PARAM.SFO" && statGet->fileListNum++ < setBuf->fileListMax) + if (!entry.is_directory) { + if (entry.name == "PARAM.SFO" || entry.name == "PARAM.PFD") + { + continue; // system files are not included in the file list + } + statGet->fileNum++; + size_kbytes += (entry.size + 1023) / 1024; // firmware rounds this value up + + if (statGet->fileListNum >= setBuf->fileListMax) + continue; + + statGet->fileListNum++; + auto& file = *file_list++; + file.size = entry.size; + file.atime = entry.atime; + file.mtime = entry.mtime; + file.ctime = entry.ctime; + strcpy_trunc(file.fileName, entry.name); + if (entry.name == "ICON0.PNG") { file.fileType = CELL_SAVEDATA_FILETYPE_CONTENT_ICON0; @@ -544,14 +561,12 @@ static NEVER_INLINE s32 savedata_op(ppu_thread& ppu, u32 operation, u32 version, file.fileType = CELL_SAVEDATA_FILETYPE_NORMALFILE; } - file.size = entry.size; - file.atime = entry.atime; - file.mtime = entry.mtime; - file.ctime = entry.ctime; - strcpy_trunc(file.fileName, entry.name); } } + statGet->sysSizeKB = 35; // always reported as 35 regardless of actual file sizes + statGet->sizeKB = size_kbytes ? size_kbytes + statGet->sysSizeKB : 0; + // Stat Callback funcStat(ppu, result, statGet, statSet); @@ -823,6 +838,18 @@ static NEVER_INLINE s32 savedata_get_list_item(vm::cptr dirName, vm::ptrmtime = dir_info.mtime; } + if (sizeKB) + { + u32 size_kbytes = 0; + + for (const auto& entry : fs::dir(save_path)) + { + size_kbytes += (entry.size + 1023) / 1024; // firmware rounds this value up + } + + *sizeKB = size_kbytes; + } + if (bind) { //TODO: Set bind in accordance to any problems