Пример #1
0
            public BlockStreamWriter(FragmentedFile file, long ordinal)
                : this(file)
            {
                _current = _first = new FileBlock(file._blockSize, file._useAlignedIo);
                _file.ReadBlock(ordinal, _current, file._blockSize, BlockFlags.ExternalBlock);

                if ((_current.Flags & BlockFlags.ExternalBlock) != BlockFlags.ExternalBlock)
                {
                    throw new InvalidOperationException();
                }

                if ((_current.Flags & BlockFlags.Temporary) == BlockFlags.Temporary)
                {
                    _isNew          = true;
                    _restore        = null;
                    _current.Flags &= ~BlockFlags.Temporary;
                }
                else
                {
                    _isNew               = false;
                    _restore             = _current.Clone();
                    _current.NextBlockId = 0;
                }

                _current.Length = 0;
            }
Пример #2
0
 public BlockStreamWriter(FragmentedFile file, FileBlock block)
     : this(file)
 {
     _current        = _first = block;
     _current.Flags &= ~BlockFlags.Temporary;
     _restore        = null;
     _temp           = null;
     _isNew          = true;
 }
Пример #3
0
            public BlockStreamReader(FragmentedFile file, long ordinal, BlockFlags typeExpected, bool validated)
            {
                _file      = file;
                _blockPos  = 0;
                _validated = validated;
                _block     = new FileBlock(file._blockSize, file._useAlignedIo);

                _file.ReadBlock(ordinal, _block, file._blockSize, typeExpected, _validated);
                if (_validated)
                {
                    _expectedSum = _block.CheckSum;
                    _checksum    = new Crc32();
                    _checksum.Add(_block.BlockData, _block.DataOffset, _block.Length);
                    if (_block.NextBlockId == 0 && _checksum != _expectedSum)
                    {
                        throw new InvalidDataException();
                    }
                }
            }
Пример #4
0
 private BlockStreamWriter(FragmentedFile file)
 {
     _file     = file;
     _checksum = new Crc32();
     _saved    = _reverted = false;
 }
Пример #5
0
 public BlockStreamReader(FragmentedFile file, long ordinal)
     : this(file, ordinal, BlockFlags.ExternalBlock, true)
 {
 }
            public BlockStreamWriter(FragmentedFile file, long ordinal)
                : this(file)
            {
                _current = _first = new FileBlock(file._blockSize, file._useAlignedIo);
                _file.ReadBlock(ordinal, _current, file._blockSize, BlockFlags.ExternalBlock);

                if ((_current.Flags & BlockFlags.ExternalBlock) != BlockFlags.ExternalBlock)
                    throw new InvalidOperationException();

                if ((_current.Flags & BlockFlags.Temporary) == BlockFlags.Temporary)
                {
                    _isNew = true;
                    _restore = null;
                    _current.Flags &= ~BlockFlags.Temporary;
                }
                else
                {
                    _isNew = false;
                    _restore = _current.Clone();
                    _current.NextBlockId = 0;
                }

                _current.Length = 0;
            }
 public BlockStreamWriter(FragmentedFile file, FileBlock block)
     : this(file)
 {
     _current = _first = block;
     _current.Flags &= ~BlockFlags.Temporary;
     _restore = null;
     _temp = null;
     _isNew = true;
 }
 private BlockStreamWriter(FragmentedFile file)
 {
     _file = file;
     _checksum = new Crc32();
     _saved = _reverted = false;
 }
            public BlockStreamReader(FragmentedFile file, long ordinal, BlockFlags typeExpected, bool validated)
            {
                _file = file;
                _blockPos = 0;
                _validated = validated;
                _block = new FileBlock(file._blockSize, file._useAlignedIo);

                _file.ReadBlock(ordinal, _block, file._blockSize, typeExpected, _validated);
                if (_validated)
                {
                    _expectedSum = _block.CheckSum;
                    _checksum = new Crc32();
                    _checksum.Add(_block.BlockData, _block.DataOffset, _block.Length);
                    if (_block.NextBlockId == 0 && _checksum != _expectedSum)
                        throw new InvalidDataException();
                }
            }
 public BlockStreamReader(FragmentedFile file, long ordinal)
     : this(file, ordinal, BlockFlags.ExternalBlock, true)
 { }