private void InitializeCurrentBlockBrowser() { int divisionRemainder = _dataStreamDefinition.StreamLengthInBytes % _disk.BlockSizeInBytes; if (divisionRemainder == 0) { divisionRemainder = _disk.BlockSizeInBytes; } // Note: логику по созданию я здесь оставлять не планировал. Очевидно, что она не на месте. Какое Enumerator-у дело до // того, какой у нас блок - последний или не последний? Остается на моей совести. int occupiedSpace = this.IsAtLastElement ? divisionRemainder : _disk.BlockSizeInBytes; var diskBlock = new DiskBlock(_disk, _singlyIndirectReferencesEnumerator.Current, occupiedSpace, 0); if (!this.IsAtLastElement) { _current = diskBlock; } else { _current = new DiskBlockNodeUpdating(diskBlock, _dataStreamDefinition, _streamOwningNode, _fileSystemNodeStorage); } }
public NonEmptyDiskBlockEnumerator( IVirtualDisk disk, DataStreamDefinition dataStreamDefinition, AddressingSystemParameters addressingSystemParameters, IFileSystemNodeStorage fileSystemNodeStorage, Node streamOwningNode, EnumeratorAddressable <int> doubleIndirectListEnumerator) { if (disk == null) { throw new ArgumentNullException("disk"); } if (dataStreamDefinition == null) { throw new ArgumentNullException("dataStreamDefinition"); } if (addressingSystemParameters == null) { throw new ArgumentNullException("addressingSystemParameters"); } if (fileSystemNodeStorage == null) { throw new ArgumentNullException("fileSystemNodeStorage"); } if (streamOwningNode == null) { throw new ArgumentNullException("streamOwningNode"); } if (doubleIndirectListEnumerator == null) { throw new ArgumentNullException("doubleIndirectListEnumerator"); } _disk = disk; _dataStreamDefinition = dataStreamDefinition; _addressingSystemParameters = addressingSystemParameters; _fileSystemNodeStorage = fileSystemNodeStorage; _streamOwningNode = streamOwningNode; _doubleIndirectListEnumerator = doubleIndirectListEnumerator; if (doubleIndirectListEnumerator.Count == 0) { throw new ArgumentException("doubleIndirectListEnumerator"); } _numberOfBlocks = SpaceRequirementsCalculator.GetNumberOfChunksNeededToStoreData(_dataStreamDefinition.StreamLengthInBytes, _disk.BlockSizeInBytes); _blockSizesCalculator = new AddressingBlockSizesCalculator(addressingSystemParameters.IndirectBlockReferencesCountInDoubleIndirectBlock, addressingSystemParameters.DataBlockReferencesCountInSingleIndirectBlock); _addressingSystemSizesOfLastBlocks = _blockSizesCalculator.GetSizesOfAddressingBlocksSufficientToStoreItems(_numberOfBlocks); this.SetFirstSingleIndirectBlock(); _current = new NullDiskBlock(); _position = PositionBeforeFirstElement; }
public void Reset() { _position = EnumeratorAddressable <IDiskBlock> .IndexOfPositionBeforeFirstElement; this.SetFirstSingleIndirectBlock(); _current = new NullDiskBlock(); }
public DiskBlockNodeUpdating(IDiskBlock diskBlockWrapped, DataStreamDefinition owningStreamDefinition, Node blockOwningNode, IFileSystemNodeStorage fileSystemNodeStorage) { if (diskBlockWrapped == null) { throw new ArgumentNullException("diskBlockWrapped"); } if (owningStreamDefinition == null) { throw new ArgumentNullException("owningStreamDefinition"); } if (blockOwningNode == null) { throw new ArgumentNullException("blockOwningNode"); } if (fileSystemNodeStorage == null) { throw new ArgumentNullException("fileSystemNodeStorage"); } _diskBlockWrapped = diskBlockWrapped; _owningStreamDefinition = owningStreamDefinition; _blockOwningNode = blockOwningNode; _fileSystemNodeStorage = fileSystemNodeStorage; }
public EmptyDiskBlockEnumerator() { _current = new NullDiskBlock(); }