zx_vmo_create(0x100, 0x0, &AUTO=0x0) # Create a read/write stream and initialize the seek offset to 0. zx_stream_create(0x3, r0, 0x0, &AUTO=0x0) # Write to the stream, first in write mode, then in append mode. zx_stream_writev(r1, 0x0, &AUTO=[{&AUTO='abcd', 0x4}, {&AUTO='efg', 0x3}], 0x2, &AUTO) zx_stream_writev(r1, 0x1, &AUTO=[{&AUTO='hi', 0x2}], 0x1, &AUTO) # Attempt to write with an invalid input pointer. zx_stream_writev(r1, 0x1, 0x0, 0x1, &AUTO) # ZX_ERR_INVALID_ARGS # Read from the stream. zx_stream_readv(r1, 0x0, &AUTO, 0x1, &AUTO) # Move the cursor back to the beginning of the stream. # Seek forward 1 byte from the current position in the stream. # Seeking fails if the offset (after wrapping around) falls before the beginning of the stream. # Seek to an offset past the current end of the stream. zx_stream_seek(r1, 0x0, 0x0, &AUTO) zx_stream_seek(r1, 0x1, 0x1, &AUTO) zx_stream_seek(r1, 0x0, 0xffffffffffffffff, &AUTO) # ZX_ERR_INVALID_ARGS zx_stream_seek(r1, 0x1, 0xfffffffffffffffe, &AUTO) # ZX_ERR_INVALID_ARGS zx_stream_seek(r1, 0x2, 0x1, &AUTO=0x0) # With the cursor after the end of the stream, read and write some bytes. zx_stream_readv_at(r1, 0x0, r2, &AUTO, 0x1, &AUTO) zx_stream_writev_at(r1, 0x0, r2, &AUTO=[{&AUTO='jk', 0x2}], 0x1, &AUTO)