public override void Reset() { foreach (var entry in _children) { entry.Node.Reset(); } _inode = new DirectoryInode(); }
public VfsSquashFileSystemReader(Stream stream) : base(new DiscFileSystemOptions()) { _context = new Context(); _context.SuperBlock = new SuperBlock(); _context.RawStream = stream; // Read superblock stream.Position = 0; byte[] buffer = Utilities.ReadFully(stream, _context.SuperBlock.Size); _context.SuperBlock.ReadFrom(buffer, 0); if (_context.SuperBlock.Magic != SuperBlock.SquashFsMagic) { throw new IOException("Invalid SquashFS filesystem - magic mismatch"); } if (_context.SuperBlock.Compression != 1) { throw new IOException("Unsupported compression used"); } if (_context.SuperBlock.ExtendedAttrsTableStart != -1) { throw new IOException("Unsupported extended attributes present"); } if (_context.SuperBlock.MajorVersion != 4) { throw new IOException("Unsupported file system version: " + _context.SuperBlock.MajorVersion + "." + _context.SuperBlock.MinorVersion); } // Create block caches, used to reduce the amount of I/O and decompression activity. _blockCache = new BlockCache <Block>((int)_context.SuperBlock.BlockSize, 20); _metablockCache = new BlockCache <Metablock>(MetadataBufferSize, 20); _context.ReadBlock = ReadBlock; _context.ReadMetaBlock = ReadMetaBlock; _context.InodeReader = new MetablockReader(_context, _context.SuperBlock.InodeTableStart); _context.DirectoryReader = new MetablockReader(_context, _context.SuperBlock.DirectoryTableStart); if (_context.SuperBlock.FragmentTableStart != -1) { _context.FragmentTableReaders = LoadIndirectReaders( _context.SuperBlock.FragmentTableStart, (int)_context.SuperBlock.FragmentsCount, FragmentRecord.RecordSize); } if (_context.SuperBlock.UidGidTableStart != -1) { _context.UidGidTableReaders = LoadIndirectReaders( _context.SuperBlock.UidGidTableStart, _context.SuperBlock.UidGidCount, 4); } // Bootstrap the root directory _context.InodeReader.SetPosition(_context.SuperBlock.RootInode); DirectoryInode dirInode = (DirectoryInode)Inode.Read(_context.InodeReader); RootDirectory = new Directory(_context, dirInode, _context.SuperBlock.RootInode); }