示例#1
0
           public static byte[] ToByteArray(ByteBuffer buffer, int length)
        {
            if (buffer.HasBuffer && buffer.Offset == 0)
            {
                // The backing array should work out fine for us
                return buffer.Buffer;
            }

            byte[] data = new byte[length];
            buffer.Read(data);
            return data;
        }
示例#2
0
        public static byte[] ToByteArray(ByteBuffer buffer, int length)
        {
            if (buffer.HasBuffer && buffer.Offset == 0)
            {
                // The backing array should work out fine for us
                return(buffer.Buffer);
            }

            byte[] data = new byte[length];
            buffer.Read(data);
            return(data);
        }
        public override void Write(ByteBuffer src, long position)
        {
            long endPosition = position + src.Length;

            if (endPosition > buffer.Length)
            {
                Extend(endPosition);
            }

            // Now copy
            src.Read(buffer, (int)position, src.Length);

            // Update size if needed
            if (endPosition > size)
            {
                size = endPosition;
            }
        }
示例#4
0
        public ByteBuffer Write(ByteBuffer src)
        {
            if (src == this)
            {
                throw new ArgumentException();
            }
            int n = src.Remain;

            if (n > this.Remain)
            {
                throw new IndexOutOfRangeException();
            }

            for (int i = 0; i < n; i++)
            {
                Write(src.Read());
            }
            return(this);
        }
示例#5
0
        //public static BATBlock CreateBATBlock(POIFSBigBlockSize bigBlockSize, byte[] data)
        public static BATBlock CreateBATBlock(POIFSBigBlockSize bigBlockSize, ByteBuffer data)
        {
            // Create an empty block
            BATBlock block = new BATBlock(bigBlockSize);

            // Fill it
            byte[] buffer = new byte[LittleEndianConsts.INT_SIZE];
            //int index = 0;
            for (int i = 0; i < block._values.Length; i++)
            {
                //data.Read(buffer, 0, buffer.Length);
                //for (int j = 0; j < buffer.Length; j++, index++)
                 //   buffer[j] = data[index];
                data.Read(buffer);
                block._values[i] = LittleEndian.GetInt(buffer);
            }
            block.RecomputeFree();

            // All done
            return block;
        }
示例#6
0
        public ByteBuffer Write(ByteBuffer src)
        {
            if (src == this)
                throw new ArgumentException();
            int n = src.Remain;

            if (n > this.Remain)
                throw new IndexOutOfRangeException();

            for (int i = 0; i < n; i++)
                Write(src.Read());
            return this;
        }