Module io
Additions to the io module
Functions
| catdir (...) | Concatenate two or more directories into a path, removing the trailing slash. |
| catfile (...) | Concatenate one or more directories and a filename into a path. |
| processFiles (f) | Process files specified on the command-line. |
| readlines (h) | Read a file or file handle into a list of lines. |
| shell (c) | Perform a shell command and return its output. |
| slurp (h) | Slurp a file handle. |
| splitdir (path) | Split a directory path into components. |
| writelines (h, ...) | Write values adding a newline after each. |
Functions
- catdir (...)
-
Concatenate two or more directories into a path, removing the trailing slash.
Parameters
- ...: path components
Return value:
path - catfile (...)
-
Concatenate one or more directories and a filename into a path.
Parameters
- ...: path components
Return value:
path - processFiles (f)
-
Process files specified on the command-line. If no files given, process
io.stdin; in list of files,-meansio.stdin.
FIXME: Make the file list an argument to the function.Parameters
-
f: function to process files with, which is passed
(name, arg_no)
-
f: function to process files with, which is passed
- readlines (h)
-
Read a file or file handle into a list of lines.
Parameters
-
h: file handle or name (default:
io.input ()); if h is a handle, the file is closed after reading
Return value:
list of lines -
h: file handle or name (default:
- shell (c)
-
Perform a shell command and return its output.
Parameters
- c: command
Return value:
output, or nil if error - slurp (h)
-
Slurp a file handle.
Parameters
-
h: file handle or name (default:
io.input ())
Return value:
contents of file or handle, or nil if error -
h: file handle or name (default:
- splitdir (path)
-
Split a directory path into components. Empty components are retained: the root directory becomes
{"", ""}.Parameters
- path: path
Return value:
list of path components - writelines (h, ...)
-
Write values adding a newline after each.
Parameters
-
h: file handle (default:
io.output () - ...: values to write (as for write)
-
h: file handle (default: