Пример #1
0
        protected override Block ReadBlock(int index, [NotNull] PipelineInfo pipelineInfo)
        {
            var uncompressedStream = MemoryStreamManager.GetStream("Uncompressed");

            SourceStream.CopyBlockTo(uncompressedStream, pipelineInfo.BlockSize);
            uncompressedStream.Position = 0;

            return(new Block(index, uncompressedStream));
        }
Пример #2
0
        protected override Block ReadBlock(int index, PipelineInfo pipelineInfo)
        {
            var position = ReadInt32();

            if (position < 0 || position >= pipelineInfo.BlockCount)
            {
                throw new PipelineException("Source file corrupted.");
            }

            var compressedLength = ReadInt32();

            if (compressedLength <= 0)
            {
                throw new PipelineException("Source file corrupted.");
            }

            var compressedStream = MemoryStreamManager.GetStream("Compressed");

            SourceStream.CopyBlockTo(compressedStream, compressedLength);
            compressedStream.Position = 0;

            return(new Block(position, compressedStream));
        }
Пример #3
0
 protected abstract void BeforeBlockWrite([NotNull] Block block, [NotNull] PipelineInfo pipelineInfo);
Пример #4
0
 protected abstract void PrepareForWrite([NotNull] PipelineInfo pipelineInfo);
Пример #5
0
 protected abstract Block ReadBlock(int index, [NotNull] PipelineInfo pipelineInfo);
Пример #6
0
 protected override void BeforeBlockWrite(Block block, PipelineInfo pipelineInfo)
 {
     // Write block header
     Write(block.Position);
     Write((int)block.Data.Length);
 }
Пример #7
0
 protected override void PrepareForWrite(PipelineInfo pipelineInfo)
 {
     // Write file header
     Write(pipelineInfo.UncompressedSize);
     Write(pipelineInfo.BlockSize);
 }
Пример #8
0
        protected override void BeforeBlockWrite([NotNull] Block block, [NotNull] PipelineInfo pipelineInfo)
        {
            var offset = (long)block.Position * pipelineInfo.BlockSize;

            DestinationStream.Seek(offset, SeekOrigin.Begin);
        }
Пример #9
0
 protected override void PrepareForWrite([NotNull] PipelineInfo pipelineInfo)
 {
     DestinationStream.SetLength(pipelineInfo.UncompressedSize);
 }