class BinData::IO::Write

def with_buffer(n, &block)

bytes.
are written inside the block, the remainder will be padded with '\0'
+block+ will be contained within this buffer. If less than +n+ bytes
Sets a buffer of +n+ bytes on the io stream. Any writes inside the
def with_buffer(n, &block)
  prev = @bytes_remaining
  if prev
    n = prev if n > prev
    prev -= n
  end
  @bytes_remaining = n
  begin
    block.call
    write_raw("\0" * @bytes_remaining)
  ensure
    @bytes_remaining = prev
  end
end