mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-03-29 22:20:48 +00:00
cellFs: Improve cellFsGetDirectoryEntries
This commit is contained in:
parent
28fb0d1741
commit
9d2c9e5d62
@ -639,7 +639,9 @@ error_code sys_fs_stat(ppu_thread& ppu, vm::cptr<char> path, vm::ptr<CellFsStat>
|
|||||||
const std::string_view vpath = path.get_ptr();
|
const std::string_view vpath = path.get_ptr();
|
||||||
const std::string local_path = vfs::get(vpath);
|
const std::string local_path = vfs::get(vpath);
|
||||||
|
|
||||||
if (vpath.find_first_not_of('/') == -1)
|
const auto first_name_ch = vpath.find_first_not_of('/');
|
||||||
|
|
||||||
|
if (first_name_ch == -1)
|
||||||
{
|
{
|
||||||
*sb = {CELL_FS_S_IFDIR | 0444};
|
*sb = {CELL_FS_S_IFDIR | 0444};
|
||||||
return CELL_OK;
|
return CELL_OK;
|
||||||
@ -693,9 +695,10 @@ error_code sys_fs_stat(ppu_thread& ppu, vm::cptr<char> path, vm::ptr<CellFsStat>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const bool supports_id = vpath.size() < (first_name_ch + 8) || !vpath.compare(first_name_ch, 8, "dev_hdd1"sv); // TODO
|
||||||
sb->mode = info.is_directory ? CELL_FS_S_IFDIR | 0777 : CELL_FS_S_IFREG | 0666;
|
sb->mode = info.is_directory ? CELL_FS_S_IFDIR | 0777 : CELL_FS_S_IFREG | 0666;
|
||||||
sb->uid = 0; // Always zero
|
sb->uid = supports_id ? 0 : -1;
|
||||||
sb->gid = 0; // Always zero
|
sb->gid = supports_id ? 0 : -1;
|
||||||
sb->atime = info.atime;
|
sb->atime = info.atime;
|
||||||
sb->mtime = info.mtime;
|
sb->mtime = info.mtime;
|
||||||
sb->ctime = info.ctime;
|
sb->ctime = info.ctime;
|
||||||
@ -727,9 +730,10 @@ error_code sys_fs_fstat(ppu_thread& ppu, u32 fd, vm::ptr<CellFsStat> sb)
|
|||||||
|
|
||||||
const fs::stat_t& info = file->file.stat();
|
const fs::stat_t& info = file->file.stat();
|
||||||
|
|
||||||
|
const bool supports_id = std::memcmp("/dev_hdd1", file->name.data(), 9) != 0; // TODO
|
||||||
sb->mode = info.is_directory ? CELL_FS_S_IFDIR | 0777 : CELL_FS_S_IFREG | 0666;
|
sb->mode = info.is_directory ? CELL_FS_S_IFDIR | 0777 : CELL_FS_S_IFREG | 0666;
|
||||||
sb->uid = 0; // Always zero
|
sb->uid = supports_id ? 0 : -1;
|
||||||
sb->gid = 0; // Always zero
|
sb->gid = supports_id ? 0 : -1;
|
||||||
sb->atime = info.atime;
|
sb->atime = info.atime;
|
||||||
sb->mtime = info.mtime;
|
sb->mtime = info.mtime;
|
||||||
sb->ctime = info.ctime; // ctime may be incorrect
|
sb->ctime = info.ctime; // ctime may be incorrect
|
||||||
@ -1218,15 +1222,21 @@ error_code sys_fs_fcntl(ppu_thread& ppu, u32 fd, u32 op, vm::ptr<void> _arg, u32
|
|||||||
return CELL_EBADF;
|
return CELL_EBADF;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (; arg->_size < arg->max; arg->_size++)
|
arg->_size = 0; // This write is not really useful for cellFs but do it anyways
|
||||||
|
|
||||||
|
// NOTE: This function is actually capable of reading only one entry at a time
|
||||||
|
if (arg->max)
|
||||||
{
|
{
|
||||||
|
std::memset(arg->ptr.get_ptr(), 0, arg->max * arg->ptr.size());
|
||||||
|
|
||||||
if (auto* info = directory->dir_read())
|
if (auto* info = directory->dir_read())
|
||||||
{
|
{
|
||||||
auto& entry = arg->ptr[arg->_size];
|
auto& entry = arg->ptr[arg->_size++];
|
||||||
|
|
||||||
|
const bool supports_id = std::memcmp("/dev_hdd1", directory->name.data(), 9) != 0; // TODO
|
||||||
entry.attribute.mode = info->is_directory ? CELL_FS_S_IFDIR | 0777 : CELL_FS_S_IFREG | 0666;
|
entry.attribute.mode = info->is_directory ? CELL_FS_S_IFDIR | 0777 : CELL_FS_S_IFREG | 0666;
|
||||||
entry.attribute.uid = 0;
|
entry.attribute.uid = supports_id ? 0 : -1;
|
||||||
entry.attribute.gid = 0;
|
entry.attribute.gid = supports_id ? 0 : -1;
|
||||||
entry.attribute.atime = info->atime;
|
entry.attribute.atime = info->atime;
|
||||||
entry.attribute.mtime = info->mtime;
|
entry.attribute.mtime = info->mtime;
|
||||||
entry.attribute.ctime = info->ctime;
|
entry.attribute.ctime = info->ctime;
|
||||||
@ -1237,10 +1247,6 @@ error_code sys_fs_fcntl(ppu_thread& ppu, u32 fd, u32 op, vm::ptr<void> _arg, u32
|
|||||||
entry.entry_name.d_namlen = u8(std::min<size_t>(info->name.size(), CELL_FS_MAX_FS_FILE_NAME_LENGTH));
|
entry.entry_name.d_namlen = u8(std::min<size_t>(info->name.size(), CELL_FS_MAX_FS_FILE_NAME_LENGTH));
|
||||||
strcpy_trunc(entry.entry_name.d_name, info->name);
|
strcpy_trunc(entry.entry_name.d_name, info->name);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
arg->_code = CELL_OK;
|
arg->_code = CELL_OK;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user