Pike v8.0 release 1738

Method Stdio.read_bytes()


Method read_bytes

string read_bytes(string filename, int start, int len)
string read_bytes(string filename, int start)
string read_bytes(string filename)

Description

Read len number of bytes from a regular file filename starting at byte start, and return it as a string.

If len is omitted, the rest of the file will be returned.

If start is also omitted, the entire file will be returned.

Throws

Throws an error on any I/O error except when the file doesn't exist.

Returns

Returns 0 (zero) if the file doesn't exist or if start is beyond the end of it.

Returns a string with the requested data otherwise.

See also

read_file, write_file(), append_file()