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 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; } }
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); }
//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; }
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; }