Home  Contents

rawio:slurp

Rawio Core4 Lua Event System

SYNOPSIS

  1. rawio.slurp(filename[, maxlen])
  2. handle:slurp([maxlen])

DESCRIPTION

Reads the full contents of the file into a string.

Reads at most maxlen bytes of data from the open file. The default is to read the full file.

This function will not stop reading until it encounters an error, an end-of-file condition or has read the requested length.

RETURN VALUE

On success, returns a string with the data that was read.

On error, the first form returns three values: nil, a string describing the error (The result of the C library call strerror() on the errno code) and the errno number from the standard C library.

On error, the second form returns nil. The error can be retrieved using rawio:lastError().

SEE ALSO