Module std.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. |
die (...) | Die with error. |
process_files (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. |
warn (...) | Give warning with the name of program and file (if any). |
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
Returns:
-
path
- catfile (...)
-
Concatenate one or more directories and a filename into a path.
Parameters:
- ... path components
Returns:
-
path
- die (...)
-
Die with error.
Parameters:
- ... arguments for format
- process_files (f)
-
Process files specified on the command-line.
If no files given, process
io.stdin
; in list of files,-
meansio.stdin
.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
Returns:
-
list of lines
- h
file handle or name (default:
- shell (c)
-
Perform a shell command and return its output.
Parameters:
- c command
Returns:
-
output, or nil if error
- slurp (h)
-
Slurp a file handle.
Parameters:
- h
file handle or name (default:
io.input ()
)
Returns:
-
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
Returns:
-
list of path components
- warn (...)
-
Give warning with the name of program and file (if any).
Parameters:
- ... arguments for format
- 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: