Пример #1
0
        public int GetEntryCount()
        {
            int count = 0;

            FindPosition position = InitialPosition;
            HierarchicalRomFileTable <RomFileInfo> 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
        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 <RomFileInfo> tab = ParentFileSystem.FileTable;

            if (Mode.HasFlag(OpenDirectoryMode.Directories))
            {
                while (tab.FindNextDirectory(ref position, out string name))
                {
                    yield return(new DirectoryEntry(name, PathTools.Combine(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, PathTools.Combine(FullPath, name), DirectoryEntryType.File, info.Length));
                }
            }
        }