Library lfs
Returns a directory iterator listing the contents of the given path
Each time the iterator is called with dir_obj it returns a directory entry's name as a string, or nil if there are no more entries.
Example Usage
for f in lfs.dir("/tmp") do print("file:", f) end
Functions
- dir (path)
Returns a directory iterator listing the contents of the given path
- get_path_separator ()
Returns the OS specific directory path separator.
- link (filepath, linkname, symbolic)
Creates a hard or symbolic link to a file
- mkdir (path)
Creates a new directory. The parent directory has to exist otherwise the operation will fail
- rmdir (path)
Removes an existing directory. The directory has to be empty, otherwise the operation will fail
Functions
- dir (path)
-
Returns a directory iterator listing the contents of the given path
Each time the iterator is called with dir_obj it returns a directory entry's name as a string, or nil if there are no more entries.
Parameters
- path
- string containing the directory to list
Usage:
for f in lfs.dir("/tmp") do print("file:", f) end
Return value:
iterator function returning the next file or nil when done - get_path_separator ()
-
Returns the OS specific directory path separator.
Return value:
sep string containing the path separator - link (filepath, linkname, symbolic)
-
Creates a hard or symbolic link to a file
Parameters
- filepath
- string containing the object to link to
- linkname
- string containing the name of the link
- symbolic
- [optional] boolean true if link is symbolic
Return values:
- Status (true or false)
- Error string (if status is false).
- mkdir (path)
-
Creates a new directory. The parent directory has to exist otherwise the operation will fail
Parameters
- path
- string containing the directory name to create
Return values:
- Status (true or false)
- Error string (if status is false).
- rmdir (path)
-
Removes an existing directory. The directory has to be empty, otherwise the operation will fail
Parameters
- path
- string containing the directory name to remove
Return values:
- Status (true or false)
- Error string (if status is false).