示例#1
0
        public int PushData(ByteData data, long offset)
        {
            if (this.Size == 0L)
            {
                throw new InvalidOperationException();
            }
            long size    = this.Size;
            long offset1 = offset;
            ArraySegment <byte> buffer = data.Buffer;
            int count1       = buffer.Count;
            int writableSize = SinkUtil.GetWritableSize(size, offset1, count1);

            if (writableSize == 0)
            {
                return(0);
            }
            this.m_stream.Seek(offset, SeekOrigin.Begin);
            Stream stream = this.m_stream;

            buffer = data.Buffer;
            byte[] array = buffer.Array;
            buffer = data.Buffer;
            int offset2 = buffer.Offset;
            int count2  = writableSize;

            stream.Write(array, offset2, count2);
            this.m_status.FilledRangeList.MergingAdd(new Range(offset, (long)writableSize));
            this.m_status.IsFilled = SinkUtil.CheckIsFilled(this.m_status.FilledRangeList, this.Size);
            return(writableSize);
        }
示例#2
0
        public int PushData(ByteData data, long offset)
        {
            int writableSize = SinkUtil.GetWritableSize(this.Size, offset, data.Buffer.Count);

            if (writableSize == 0)
            {
                return(0);
            }
            Buffer.BlockCopy((Array)data.Buffer.Array, data.Buffer.Offset, (Array)this.m_buffer, (int)offset, writableSize);
            this.m_status.FilledRangeList.MergingAdd(new Range(offset, (long)writableSize));
            this.m_status.IsFilled = SinkUtil.CheckIsFilled(this.m_status.FilledRangeList, this.Size);
            return(writableSize);
        }
示例#3
0
        public int PushData(ByteData data, long offset)
        {
            int writableSize = SinkUtil.GetWritableSize(this.Size, offset, data.Buffer.Count);

            if (writableSize == 0)
            {
                return(0);
            }
            this.m_storage.Write(offset, data.Buffer.Array);
            this.m_storage.Commit();
            this.m_status.FilledRangeList.MergingAdd(new Range(offset, (long)writableSize));
            this.m_status.IsFilled = SinkUtil.CheckIsFilled(this.m_status.FilledRangeList, this.Size);
            return(writableSize);
        }
示例#4
0
        public int PushData(ByteData data, long offset)
        {
            int writableSize = SinkUtil.GetWritableSize(this.Size, offset, data.Buffer.Count);

            if (writableSize == 0)
            {
                return(0);
            }
            using (Stream stream1 = (Stream) new SubStream((Stream) new FileStream(this.m_filePath, FileMode.Open, FileAccess.ReadWrite, FileShare.None, 4096, FileOptions.RandomAccess), this.m_offset, this.Size))
            {
                stream1.Seek(offset, SeekOrigin.Begin);
                Stream stream2             = stream1;
                ArraySegment <byte> buffer = data.Buffer;
                byte[] array = buffer.Array;
                buffer = data.Buffer;
                int offset1 = buffer.Offset;
                int count   = writableSize;
                stream2.Write(array, offset1, count);
            }
            this.m_status.FilledRangeList.MergingAdd(new Range(offset, (long)writableSize));
            this.m_status.IsFilled = SinkUtil.CheckIsFilled(this.m_status.FilledRangeList, this.Size);
            return(writableSize);
        }