diff --git a/app/src/main/cpp/skyline/vfs/rom_filesystem.cpp b/app/src/main/cpp/skyline/vfs/rom_filesystem.cpp index 8bf927e13..c9d79770b 100644 --- a/app/src/main/cpp/skyline/vfs/rom_filesystem.cpp +++ b/app/src/main/cpp/skyline/vfs/rom_filesystem.cpp @@ -28,25 +28,27 @@ namespace skyline::vfs { } void RomFileSystem::TraverseDirectory(u32 offset, const std::string &path) { - auto entry{backing->Read(header.dirMetaTableOffset + offset)}; + RomFsDirectoryEntry entry; + do { + entry = backing->Read(header.dirMetaTableOffset + offset); - std::string childPath(path); - if (entry.nameSize) { - std::vector name(entry.nameSize); - backing->Read(span(name), header.dirMetaTableOffset + offset + sizeof(RomFsDirectoryEntry)); - childPath = path + (path.empty() ? "" : "/") + std::string(name.data(), entry.nameSize); - } + std::string childPath(path); + if (entry.nameSize) { + std::vector name(entry.nameSize); + backing->Read(span(name), header.dirMetaTableOffset + offset + sizeof(RomFsDirectoryEntry)); + childPath = path + (path.empty() ? "" : "/") + std::string(name.data(), entry.nameSize); + } - directoryMap.emplace(childPath, entry); + directoryMap.emplace(childPath, entry); - if (entry.fileOffset != constant::RomFsEmptyEntry) - TraverseFiles(entry.fileOffset, childPath); + if (entry.fileOffset != constant::RomFsEmptyEntry) + TraverseFiles(entry.fileOffset, childPath); - if (entry.childOffset != constant::RomFsEmptyEntry) - TraverseDirectory(entry.childOffset, childPath); + if (entry.childOffset != constant::RomFsEmptyEntry) + TraverseDirectory(entry.childOffset, childPath); - if (entry.siblingOffset != constant::RomFsEmptyEntry) - TraverseDirectory(entry.siblingOffset, path); + offset = entry.siblingOffset; + } while (entry.siblingOffset != constant::RomFsEmptyEntry); } std::shared_ptr RomFileSystem::OpenFileImpl(const std::string &path, Backing::Mode mode) {