Write a byte chunk to the stream with magics, length, and padding.
(stream, buf)
| 221 | |
| 222 | |
| 223 | def write_chunk(stream, buf): |
| 224 | """Write a byte chunk to the stream with magics, length, and padding.""" |
| 225 | nbytes = bytelen(buf) |
| 226 | stream.write(magic_bytes) |
| 227 | stream.write(struct.pack("@q", nbytes)) |
| 228 | stream.write(bytedata(buf)) |
| 229 | padding = roundup(nbytes) - nbytes |
| 230 | if padding > 0: |
| 231 | stream.write(b"\0" * padding) |
| 232 | |
| 233 | |
| 234 | def read_chunk(stream): |