Extracted from Pike v7.6 release 61 at 2005-12-30.
pike.ida.liu.se
[Top]
Stdio
Stdio.File

Method Stdio.File()->write()


Method write

int write(string data)
int write(string format, mixed ... extras)
int write(array(string) data)
int write(array(string) format, mixed ... extras)

Description

Write data to a file or a stream.

Writes data and returns the number of bytes that were actually written. It can be less than the size of the given data if

  • some data was written successfully and then something went wrong, or

  • nonblocking mode is used and not all data could be written without blocking.

-1 is returned if something went wrong and no bytes were written. If only some data was written due to an error and that error persists, then a later call to write() will fail and return -1.

If everything went fine, a call to errno() directly afterwards will return zero.

If data is an array of strings, they will be written sequence.

If more than one argument is given, sprintf() will be used to format them using format . If format is an array, the strings in it are concatenated and the result is used as format string.

Note

Writing of wide strings is not supported. You have to encode the data somehow, e.g. with string_to_utf8 or with one of the charsets supported by Locale.Charset.encoder .

See also

read() , write_oob()