public IChunkStorageWriter <T> OpenForWrite() { _logger.Debug($"File '{_fileName}' was opened for write at position {_currentPosition}."); var fileStream = FileWithBuffer.OpenAppend(_fileName, _fileBuffer); fileStream.Seek(_currentPosition, SeekOrigin.Begin); return(new ChunkFileStorageWriter( fileStream, _readerWriter, this)); }
public IEnumerable <T> OpenForRead(long size) { if (size > _currentPosition) { throw new IndexOutOfRangeException(); } var fileStream = FileWithBuffer.OpenRead(_fileName, _fileBuffer); long endPosition = _currentPosition; _currentPosition -= size; _logger.Debug($"File '{_fileName}' was opened for read from position {_currentPosition} to {endPosition}."); var rangeStream = new RangeStream(fileStream, _currentPosition, endPosition); return(_readerWriter.ReadFromStream(rangeStream)); }