mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-16 23:17:29 +00:00
cellFsGetDirectoryEntries improved
This commit is contained in:
parent
73b00b844b
commit
339021ac15
@ -26,14 +26,23 @@ std::unique_ptr<wchar_t> ConvertUTF8ToWChar(const std::string& source)
|
||||
return buffer;
|
||||
}
|
||||
|
||||
time_t to_time_t(const LARGE_INTEGER& ft)
|
||||
time_t to_time_t(const ULARGE_INTEGER& ft)
|
||||
{
|
||||
return ft.QuadPart / 10000000ULL - 11644473600ULL;
|
||||
}
|
||||
|
||||
time_t to_time_t(const LARGE_INTEGER& ft)
|
||||
{
|
||||
ULARGE_INTEGER v;
|
||||
v.LowPart = ft.LowPart;
|
||||
v.HighPart = ft.HighPart;
|
||||
|
||||
return to_time_t(v);
|
||||
}
|
||||
|
||||
time_t to_time_t(const FILETIME& ft)
|
||||
{
|
||||
LARGE_INTEGER v;
|
||||
ULARGE_INTEGER v;
|
||||
v.LowPart = ft.dwLowDateTime;
|
||||
v.HighPart = ft.dwHighDateTime;
|
||||
|
||||
|
@ -217,30 +217,61 @@ s32 cellFsGetDirectoryEntries(u32 fd, vm::ptr<CellFsDirectoryEntry> entries, u32
|
||||
return CELL_FS_EBADF;
|
||||
}
|
||||
|
||||
const DirEntryInfo* info = directory->Read();
|
||||
if (info)
|
||||
u32 count = 0;
|
||||
|
||||
entries_size /= sizeof(CellFsDirectoryEntry);
|
||||
|
||||
for (; count < entries_size; count++)
|
||||
{
|
||||
entries->attribute.mode =
|
||||
CELL_FS_S_IRUSR | CELL_FS_S_IWUSR | CELL_FS_S_IXUSR |
|
||||
CELL_FS_S_IRGRP | CELL_FS_S_IWGRP | CELL_FS_S_IXGRP |
|
||||
CELL_FS_S_IROTH | CELL_FS_S_IWOTH | CELL_FS_S_IXOTH;
|
||||
if (const auto info = directory->Read())
|
||||
{
|
||||
s32 mode = 0;
|
||||
|
||||
entries->attribute.uid = 0;
|
||||
entries->attribute.gid = 0;
|
||||
entries->attribute.atime = 0; //TODO
|
||||
entries->attribute.mtime = 0; //TODO
|
||||
entries->attribute.ctime = 0; //TODO
|
||||
entries->attribute.blksize = 4096;
|
||||
if (info->flags & DirEntry_PermReadable)
|
||||
{
|
||||
mode |= CELL_FS_S_IRUSR | CELL_FS_S_IRGRP | CELL_FS_S_IROTH;
|
||||
}
|
||||
|
||||
entries->entry_name.d_type = (info->flags & DirEntry_TypeFile) ? CELL_FS_TYPE_REGULAR : CELL_FS_TYPE_DIRECTORY;
|
||||
entries->entry_name.d_namlen = u8(std::min<size_t>(info->name.length(), CELL_FS_MAX_FS_FILE_NAME_LENGTH));
|
||||
strcpy_trunc(entries->entry_name.d_name, info->name);
|
||||
*data_count = 1;
|
||||
if (info->flags & DirEntry_PermWritable)
|
||||
{
|
||||
mode |= CELL_FS_S_IWUSR | CELL_FS_S_IWGRP | CELL_FS_S_IWOTH;
|
||||
}
|
||||
|
||||
if (info->flags & DirEntry_PermExecutable)
|
||||
{
|
||||
mode |= CELL_FS_S_IXUSR | CELL_FS_S_IXGRP | CELL_FS_S_IXOTH;
|
||||
}
|
||||
|
||||
if (info->flags & DirEntry_TypeDir)
|
||||
{
|
||||
mode |= CELL_FS_S_IFDIR;
|
||||
}
|
||||
|
||||
if (info->flags & DirEntry_TypeFile)
|
||||
{
|
||||
mode |= CELL_FS_S_IFREG;
|
||||
}
|
||||
|
||||
entries[count].attribute.mode = mode;
|
||||
entries[count].attribute.uid = 1; // ???
|
||||
entries[count].attribute.gid = 1; // ???
|
||||
entries[count].attribute.atime = info->access_time;
|
||||
entries[count].attribute.mtime = info->modify_time;
|
||||
entries[count].attribute.ctime = info->create_time;
|
||||
entries[count].attribute.size = info->size;
|
||||
entries[count].attribute.blksize = info->size ? align(info->size, 4096) : 4096;
|
||||
|
||||
entries[count].entry_name.d_type = (info->flags & DirEntry_TypeFile) ? CELL_FS_TYPE_REGULAR : CELL_FS_TYPE_DIRECTORY;
|
||||
entries[count].entry_name.d_namlen = u8(std::min<size_t>(info->name.length(), CELL_FS_MAX_FS_FILE_NAME_LENGTH));
|
||||
strcpy_trunc(entries[count].entry_name.d_name, info->name);
|
||||
}
|
||||
else
|
||||
{
|
||||
*data_count = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
*data_count = count;
|
||||
|
||||
return CELL_OK;
|
||||
}
|
||||
|
@ -420,7 +420,7 @@ void Emulator::LoadPoints(const std::string& path)
|
||||
|
||||
if (version != bpdb_version || (sizeof(u16) + break_count * sizeof(u64) + sizeof(u32) + marked_count * sizeof(u64) + sizeof(u32)) != length)
|
||||
{
|
||||
LOG_ERROR(LOADER, "'%s' is broken", path.c_str());
|
||||
LOG_ERROR(LOADER, "'%s' is broken (version=0x%x, break_count=0x%x, marked_count=0x%x, length=0x%x)", path, version, break_count, marked_count, length);
|
||||
return;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user