diff --git a/Utilities/rFile.cpp b/Utilities/rFile.cpp index 72457194ac..0e1cbd1b71 100644 --- a/Utilities/rFile.cpp +++ b/Utilities/rFile.cpp @@ -26,14 +26,23 @@ std::unique_ptr 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; diff --git a/rpcs3/Emu/FS/vfsDirBase.cpp b/rpcs3/Emu/FS/vfsDirBase.cpp index 2d54b48e42..58bd1d2ff4 100644 --- a/rpcs3/Emu/FS/vfsDirBase.cpp +++ b/rpcs3/Emu/FS/vfsDirBase.cpp @@ -63,4 +63,4 @@ const DirEntryInfo* vfsDirBase::First() { m_pos = 0; return Read(); -} \ No newline at end of file +} diff --git a/rpcs3/Emu/SysCalls/Modules/cellFs.cpp b/rpcs3/Emu/SysCalls/Modules/cellFs.cpp index 10d8cf44fc..d4d2554eba 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellFs.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellFs.cpp @@ -217,31 +217,62 @@ s32 cellFsGetDirectoryEntries(u32 fd, vm::ptr entries, u32 return CELL_FS_EBADF; } - const DirEntryInfo* info = directory->Read(); - if (info) - { - 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; + u32 count = 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; + entries_size /= sizeof(CellFsDirectoryEntry); - 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(info->name.length(), CELL_FS_MAX_FS_FILE_NAME_LENGTH)); - strcpy_trunc(entries->entry_name.d_name, info->name); - *data_count = 1; - } - else + for (; count < entries_size; count++) { - *data_count = 0; + if (const auto info = directory->Read()) + { + s32 mode = 0; + + if (info->flags & DirEntry_PermReadable) + { + mode |= CELL_FS_S_IRUSR | CELL_FS_S_IRGRP | CELL_FS_S_IROTH; + } + + 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(info->name.length(), CELL_FS_MAX_FS_FILE_NAME_LENGTH)); + strcpy_trunc(entries[count].entry_name.d_name, info->name); + } + else + { + break; + } } + *data_count = count; + return CELL_OK; } diff --git a/rpcs3/Emu/System.cpp b/rpcs3/Emu/System.cpp index 5e349058db..d7533e4374 100644 --- a/rpcs3/Emu/System.cpp +++ b/rpcs3/Emu/System.cpp @@ -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; }