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 into a list of lines and close it.
shell (c) Perform a shell command and return its output.
splitdir (path) Split a directory path into components.
writeline (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, - means io.stdin.
FIXME: Make the file list an argument to the function.

Parameters

  • f: function to process files with, which is passed (name, arg_no)
readlines (h)
Read a file into a list of lines and close it.

Parameters

  • h: file handle or name (default: io.input ())

Return value:

list of lines
shell (c)
Perform a shell command and return its output.

Parameters

  • c: command

Return value:

output, or nil if error
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
writeline (h, ...)
Write values adding a newline after each.

Parameters

  • h: file handle (default: io.output ()
  • ...: values to write (as for write)

Valid XHTML 1.0!