From daef24f02269f1e0041fb222d9bb87cda4537088 Mon Sep 17 00:00:00 2001 From: Albert Krewinkel Date: Fri, 15 Jul 2022 21:22:33 +0200 Subject: Lua: extend pandoc.system module. (#8184) The module now has the additional functions `list_directory`, `make_directory`, and `remove_directory`. This makes it easier to write cross-platform scripts that need to inspect or modify the file system. --- doc/lua-filters.md | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) (limited to 'doc') diff --git a/doc/lua-filters.md b/doc/lua-filters.md index 5f533ecfe..b4ac31479 100644 --- a/doc/lua-filters.md +++ b/doc/lua-filters.md @@ -4423,6 +4423,60 @@ Returns: - The current working directory (string). +### list\_directory {#pandoc.system.list_directory} + +`list_directory ([directory])` + +List the contents of a directory. + +Parameters: + +`directory` +: Path of the directory whose contents should be listed + (string). Defaults to `.`. + +Returns: + +- A table of all entries in `directory` without the special + entries `.` and `..`. (list of strings) + +### make\_directory {#pandoc.system.make_directory} + +`make_directory (dirname [, create_parent])` + +Create a new directory which is initially empty, or as near to +empty as the operating system allows. The function throws an +error if the directory cannot be created, e.g., if the parent +directory does not exist or if a directory of the same name is +already present. + +If the optional second parameter is provided and truthy, then all +directories, including parent directories, are created as +necessary. + +Parameters: + +`dirname` +: name of the new directory (string) + +`create_parent` +: create parent directories if necessary (boolean) + +### remove\_directory {#pandoc.system.remove_directory} + +`remove_directory (dirname [, recursive])` + +Remove an existing, empty directory. If `recursive` is given, +then delete the directory and its contents recursively. + +Parameters: + +`dirname` +: name of the directory to delete (string) + +`recursive` +: delete content recursively (boolean) + ### with\_environment {#pandoc.system.with_environment} `with_environment (environment, callback)` -- cgit v1.2.3