コード例 #1
0
        void MoveFileBlock(FileDataBlock fileBlock, long dataOffset)
        {
            // First, determine whether the next file block needs to move before this one.
            long          nextDataOffset;
            FileDataBlock nextFileBlock = GetNextFileDataBlock(fileBlock, dataOffset, out nextDataOffset);

            if (nextFileBlock != null && dataOffset + fileBlock.Length > nextFileBlock.FileOffset)
            {
                // The next block needs to move first, so do that now.
                MoveFileBlock(nextFileBlock, nextDataOffset);
            }

            // Now, move the block.
            if (fileBlock.FileOffset > dataOffset)
            {
                // Move the section to earlier in the file stream (done in chunks starting at the beginning of the section).
                byte[] buffer = new byte[COPY_BLOCK_SIZE];
                for (long relativeOffset = 0; relativeOffset < fileBlock.Length; relativeOffset += buffer.Length)
                {
                    long readOffset  = fileBlock.FileOffset + relativeOffset;
                    int  bytesToRead = (int)Math.Min(buffer.Length, fileBlock.Length - relativeOffset);
                    _stream.Position = readOffset;
                    _stream.Read(buffer, 0, bytesToRead);

                    long writeOffset = dataOffset + relativeOffset;
                    _stream.Position = writeOffset;
                    _stream.Write(buffer, 0, bytesToRead);
                }
            }
            else
            {
                // Move the section to later in the file stream (done in chunks starting at the end of the section).
                byte[] buffer = new byte[COPY_BLOCK_SIZE];
                for (long relativeOffset = 0; relativeOffset < fileBlock.Length; relativeOffset += buffer.Length)
                {
                    int  bytesToRead = (int)Math.Min(buffer.Length, fileBlock.Length - relativeOffset);
                    long readOffset  = fileBlock.FileOffset + fileBlock.Length - relativeOffset - bytesToRead;
                    _stream.Position = readOffset;
                    _stream.Read(buffer, 0, bytesToRead);

                    long writeOffset = dataOffset + fileBlock.Length - relativeOffset - bytesToRead;
                    _stream.Position = writeOffset;
                    _stream.Write(buffer, 0, bytesToRead);
                }
            }

            // This block now points to a different position in the file.
            fileBlock.SetFileOffset(dataOffset);
        }
コード例 #2
0
        // Token: 0x0600037A RID: 890 RVA: 0x00012974 File Offset: 0x00010B74
        private void MoveFileBlock(FileDataBlock fileBlock, long dataOffset)
        {
            long          dataOffset2;
            FileDataBlock nextFileDataBlock = this.GetNextFileDataBlock(fileBlock, dataOffset, out dataOffset2);

            if (nextFileDataBlock != null && dataOffset + fileBlock.Length > nextFileDataBlock.FileOffset)
            {
                this.MoveFileBlock(nextFileDataBlock, dataOffset2);
            }
            if (fileBlock.FileOffset > dataOffset)
            {
                byte[] array = new byte[4096];
                for (long num = 0L; num < fileBlock.Length; num += (long)array.Length)
                {
                    long position = fileBlock.FileOffset + num;
                    int  count    = (int)Math.Min((long)array.Length, fileBlock.Length - num);
                    this._stream.Position = position;
                    this._stream.Read(array, 0, count);
                    long position2 = dataOffset + num;
                    this._stream.Position = position2;
                    this._stream.Write(array, 0, count);
                }
            }
            else
            {
                byte[] array2 = new byte[4096];
                for (long num2 = 0L; num2 < fileBlock.Length; num2 += (long)array2.Length)
                {
                    int  num3      = (int)Math.Min((long)array2.Length, fileBlock.Length - num2);
                    long position3 = fileBlock.FileOffset + fileBlock.Length - num2 - (long)num3;
                    this._stream.Position = position3;
                    this._stream.Read(array2, 0, num3);
                    long position4 = dataOffset + fileBlock.Length - num2 - (long)num3;
                    this._stream.Position = position4;
                    this._stream.Write(array2, 0, num3);
                }
            }
            fileBlock.SetFileOffset(dataOffset);
        }
コード例 #3
0
        private void MoveFileBlock(FileDataBlock fileBlock, long dataOffset)
        {
            long          nextDataOffset;
            FileDataBlock nextFileDataBlock = this.GetNextFileDataBlock((DataBlock)fileBlock, dataOffset, out nextDataOffset);

            if (nextFileDataBlock != null && dataOffset + fileBlock.Length > nextFileDataBlock.FileOffset)
            {
                this.MoveFileBlock(nextFileDataBlock, nextDataOffset);
            }
            if (fileBlock.FileOffset > dataOffset)
            {
                byte[] buffer = new byte[4096];
                for (long index = 0; index < fileBlock.Length; index += (long)buffer.Length)
                {
                    long num   = fileBlock.FileOffset + index;
                    int  count = (int)Math.Min((long)buffer.Length, fileBlock.Length - index);
                    this._stream.Position = num;
                    this._stream.Read(buffer, 0, count);
                    this._stream.Position = dataOffset + index;
                    this._stream.Write(buffer, 0, count);
                }
            }
            else
            {
                byte[] buffer = new byte[4096];
                for (long index = 0; index < fileBlock.Length; index += (long)buffer.Length)
                {
                    int count = (int)Math.Min((long)buffer.Length, fileBlock.Length - index);
                    this._stream.Position = fileBlock.FileOffset + fileBlock.Length - index - (long)count;
                    this._stream.Read(buffer, 0, count);
                    this._stream.Position = dataOffset + fileBlock.Length - index - (long)count;
                    this._stream.Write(buffer, 0, count);
                }
            }
            fileBlock.SetFileOffset(dataOffset);
        }
コード例 #4
0
        void MoveFileBlock(FileDataBlock fileBlock, long dataOffset)
        {
            // First, determine whether the next file block needs to move before this one.
            long nextDataOffset;
			FileDataBlock nextFileBlock = GetNextFileDataBlock(fileBlock, dataOffset, out nextDataOffset);
            if (nextFileBlock != null && dataOffset + fileBlock.Length > nextFileBlock.FileOffset)
            {
                // The next block needs to move first, so do that now.
                MoveFileBlock(nextFileBlock, nextDataOffset);
            }

            // Now, move the block.
            if (fileBlock.FileOffset > dataOffset)
            {
                // Move the section to earlier in the file stream (done in chunks starting at the beginning of the section).
                byte[] buffer = new byte[COPY_BLOCK_SIZE];
                for (long relativeOffset = 0; relativeOffset < fileBlock.Length; relativeOffset += buffer.Length)
                {
                    long readOffset = fileBlock.FileOffset + relativeOffset;
                    int bytesToRead = (int)Math.Min(buffer.Length, fileBlock.Length - relativeOffset);
                    _stream.Position = readOffset;
                    _stream.Read(buffer, 0, bytesToRead);

                    long writeOffset = dataOffset + relativeOffset;
                    _stream.Position = writeOffset;
                    _stream.Write(buffer, 0, bytesToRead);
                }
            }
            else
            {
                // Move the section to later in the file stream (done in chunks starting at the end of the section).
                byte[] buffer = new byte[COPY_BLOCK_SIZE];
                for (long relativeOffset = 0; relativeOffset < fileBlock.Length; relativeOffset += buffer.Length)
                {
                    int bytesToRead = (int)Math.Min(buffer.Length, fileBlock.Length - relativeOffset);
                    long readOffset = fileBlock.FileOffset + fileBlock.Length - relativeOffset - bytesToRead;
                    _stream.Position = readOffset;
                    _stream.Read(buffer, 0, bytesToRead);

                    long writeOffset = dataOffset + fileBlock.Length - relativeOffset - bytesToRead;
                    _stream.Position = writeOffset;
                    _stream.Write(buffer, 0, bytesToRead);
                }
            }

			// This block now points to a different position in the file.
			fileBlock.SetFileOffset(dataOffset);
        }
コード例 #5
0
        void MoveFileBlock(FileDataBlock fileBlock, long dataOffset)
        {
            long nextDataOffset;
               FileDataBlock nextFileBlock = GetNextFileDataBlock(fileBlock, dataOffset, out nextDataOffset);
            if (nextFileBlock != null && dataOffset + fileBlock.Length > nextFileBlock.FileOffset)
            {

                MoveFileBlock(nextFileBlock, nextDataOffset);
            }

            if (fileBlock.FileOffset > dataOffset)
            {

                byte[] buffer = new byte[COPY_BLOCK_SIZE];
                for (long relativeOffset = 0; relativeOffset < fileBlock.Length; relativeOffset += buffer.Length)
                {
                    long readOffset = fileBlock.FileOffset + relativeOffset;
                    int bytesToRead = (int)Math.Min(buffer.Length, fileBlock.Length - relativeOffset);
                    _fileStream.Position = readOffset;
                    _fileStream.Read(buffer, 0, bytesToRead);

                    long writeOffset = dataOffset + relativeOffset;
                    _fileStream.Position = writeOffset;
                    _fileStream.Write(buffer, 0, bytesToRead);
                }
            }
            else
            {

                byte[] buffer = new byte[COPY_BLOCK_SIZE];
                for (long relativeOffset = 0; relativeOffset < fileBlock.Length; relativeOffset += buffer.Length)
                {
                    int bytesToRead = (int)Math.Min(buffer.Length, fileBlock.Length - relativeOffset);
                    long readOffset = fileBlock.FileOffset + fileBlock.Length - relativeOffset - bytesToRead;
                    _fileStream.Position = readOffset;
                    _fileStream.Read(buffer, 0, bytesToRead);

                    long writeOffset = dataOffset + fileBlock.Length - relativeOffset - bytesToRead;
                    _fileStream.Position = writeOffset;
                    _fileStream.Write(buffer, 0, bytesToRead);
                }
            }

               fileBlock.SetFileOffset(dataOffset);
        }