lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Am 23.02.2016 um 23:00 schröbte Sean Conner:

   It's not documented (at least, I didn't see it mentioned in the
description for io.open() for Lua 5.1, 5.2 or 5.3), but Lua does return a
third parameter for io.open():

For Lua 5.1: http://www.lua.org/manual/5.1/manual.html#5.7
For Lua 5.2: http://www.lua.org/manual/5.2/manual.html#6.8
For Lua 5.3: http://www.lua.org/manual/5.3/manual.html#6.8

Unless otherwise stated, all I/O functions return nil on failure
(plus an error message as a second result and a system-dependent
error code as a third result) and some value different from nil on
success. On non-POSIX systems, the computation of the error message
and error code in case of errors may be not thread safe, because
they rely on the global C variable errno.

The weird thing is that the entry for `io.open` *does* state otherwise:

This function opens a file, in the mode specified in the string mode.
It returns a new file handle, or, in case of errors, nil plus an
error message.

Philipp