public static void Write(BinaryWriterFast stream, long value, long maximumSize) { do { // Write byte byte currentByte = unchecked ((byte)(value & 0x7F)); if (maximumSize >> 6 == 0 || maximumSize >> 6 == -1) { stream.Write(currentByte); if (value >> 6 != 0 && value >> 6 != -1) { throw new OverflowException("Unable to write integer because the available space overflowed."); } return; } stream.Write((byte)(currentByte | 0x80)); // Move data to next byte value >>= 7; maximumSize >>= 7; } while (true); }
public void WriteChunkEnd() { _writer.Write((byte)0); }
public void ToStream(BinaryWriterFast stream) { LEB128.Write(stream, _idLength); stream.Write(_idBytes, 0, _idLength); }
public ChunkWriter(byte[] magicNumber, BinaryWriterFast fastWriter) { fastWriter.Write(magicNumber, 0, magicNumber.Length); fastWriter.Write(BitConverter.GetBytes(0), 0, 4); // @FIXME: where is the compression handling, as above? _writer = fastWriter; }