write


Description:

public abstract ssize_t write (uint8[] buffer, Cancellable? cancellable = null) throws IOError

Tries to write buffer.length bytes from buffer into the stream.

Will block during the operation.

If count is 0, returns 0 and does nothing. A value of buffer.length larger than g_maxssize will cause a g_io_error_invalid_argument error.

On success, the number of bytes written to the stream is returned. It is not an error if this is not the same as the requested size, as it can happen e.g. on a partial I/O error, or if there is not enough storage in the stream. All writes block until at least one byte is written or an error occurs; 0 is never returned (unless buffer.length is 0).

If cancellable is not null, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error g_io_error_cancelled will be returned. If an operation was partially finished when the operation was cancelled the partial result will be returned, without an error.

On error -1 is returned and throws is set accordingly.

Parameters:

this

a OutputStream.

buffer

the buffer containing the data to write.

cancellable

optional cancellable object

count

the number of bytes to write

Returns:

Number of bytes written, or -1 on error