예제 #1
0
        public int GetEntryCount()
        {
            int count = 0;

            FindPosition             position = InitialPosition;
            HierarchicalRomFileTable tab      = ParentFileSystem.FileTable;

            if (Mode.HasFlag(OpenDirectoryMode.Directories))
            {
                while (tab.FindNextDirectory(ref position, out string _))
                {
                    count++;
                }
            }

            if (Mode.HasFlag(OpenDirectoryMode.Files))
            {
                while (tab.FindNextFile(ref position, out RomFileInfo _, out string _))
                {
                    count++;
                }
            }

            return(count);
        }
예제 #2
0
        // todo Don't parse entire table when opening
        public RomFsFileSystem(IStorage storage)
        {
            BaseStorage = storage;
            Header      = new RomfsHeader(storage.AsFile(OpenMode.Read));

            IStorage dirHashTable   = storage.Slice(Header.DirHashTableOffset, Header.DirHashTableSize);
            IStorage dirEntryTable  = storage.Slice(Header.DirMetaTableOffset, Header.DirMetaTableSize);
            IStorage fileHashTable  = storage.Slice(Header.FileHashTableOffset, Header.FileHashTableSize);
            IStorage fileEntryTable = storage.Slice(Header.FileMetaTableOffset, Header.FileMetaTableSize);

            FileTable = new HierarchicalRomFileTable(dirHashTable, dirEntryTable, fileHashTable, fileEntryTable);
        }
예제 #3
0
        public IEnumerable <DirectoryEntry> Read()
        {
            FindPosition             position = InitialPosition;
            HierarchicalRomFileTable tab      = ParentFileSystem.FileTable;

            if (Mode.HasFlag(OpenDirectoryMode.Directories))
            {
                while (tab.FindNextDirectory(ref position, out string name))
                {
                    yield return(new DirectoryEntry(name, FullPath + '/' + name, DirectoryEntryType.Directory, 0));
                }
            }

            if (Mode.HasFlag(OpenDirectoryMode.Files))
            {
                while (tab.FindNextFile(ref position, out RomFileInfo info, out string name))
                {
                    yield return(new DirectoryEntry(name, FullPath + '/' + name, DirectoryEntryType.File, info.Length));
                }
            }
        }