Skip to content

Commit

Permalink
sys_fs_stat: support split files
Browse files Browse the repository at this point in the history
Was forgotten after sys_fs_open
  • Loading branch information
Nekotekina committed Aug 30, 2018
1 parent f933947 commit c49c7de
Showing 1 changed file with 34 additions and 4 deletions.
38 changes: 34 additions & 4 deletions rpcs3/Emu/Cell/lv2/sys_fs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -578,11 +578,41 @@ error_code sys_fs_stat(vm::cptr<char> path, vm::ptr<CellFsStat> sb)
{
switch (auto error = fs::g_tls_error)
{
case fs::error::noent: return {CELL_ENOENT, path};
default: sys_fs.error("sys_fs_stat(): unknown error %s", error);
}
case fs::error::noent:
{
// Try to analyse split file (TODO)
u64 total_size = 0;
u32 total_count = 0;

return {CELL_EIO, path};
for (u32 i = 66600; i <= 66699; i++)
{
if (fs::stat(fmt::format("%s.%u", local_path, i), info) && !info.is_directory)
{
total_size += info.size;
total_count++;
}
else
{
break;
}
}

// Use attributes from the first fragment (consistently with sys_fs_open+fstat)
if (total_count > 1 && fs::stat(local_path + ".66600", info) && !info.is_directory)
{
// Success
info.size = total_size;
break;
}

return {CELL_ENOENT, path};
}
default:
{
sys_fs.error("sys_fs_stat(): unknown error %s", error);
return {CELL_EIO, path};
}
}
}

sb->mode = info.is_directory ? CELL_FS_S_IFDIR | 0777 : CELL_FS_S_IFREG | 0666;
Expand Down

0 comments on commit c49c7de

Please sign in to comment.