the number of bytes written, or -1 on error (including G_IO_ERROR_WOULD_BLOCK).
GException on failure.