-
Notifications
You must be signed in to change notification settings - Fork 0
File system
The Lua RTOS file system functions provides access to the supported file systems. Some functions, such as create a directory, are provided as an extension of the Lua os and module.
File access functions are provided through the standard Lua io module. This functions are not covered in this wiki.
The functions of this module are organized in the following categories:
List the path contents.
Arguments:
- path: directory path. This argument it's optional, and if is not provided the contents of the current directory are listed. Path can be absolute or relative to current working directory.
Returns: nothing
/> os.ls("/")
d - tmp
d - www
d - conf
d - log
d - lib
f 27 test1.lua
f 956 autorun.lua
f 1871 lcd.lua
Directory contents is listed on the screen in columns (separated by tab):
- first column: entry type (d = directory / f = file)
- second column: entry size in bytes
- third column: entry name
Change the current working directory.
Arguments:
- path: directory path. Path can be absolute or relative to current working directory.
Returns: nothing.
/> os.cd("/examples")
/examples >
Get the current working directory.
Arguments: nothing
Returns: the current directory
/examples > os.pwd()
/examples
Make a directory.
Arguments:
- directory path. Path can be absolute or relative to current working directory.
Returns: true if success
-- Make a new directory named test into the current working directory
os.mkdir("test")
true
Remove a file or a directory.
Arguments:
- file or directory path. Path can be absolute or relative to current working directory.
Returns: nothing or an error.
Rename a file or a directory.
Arguments:
- old path: file or directory path to rename. Path can be absolute or relative to current working directory.
- new path: file or directory new path. Path can be absolute or relative to current working directory.
Returns: nothing or an error.
Copy a file.
Arguments:
- source path: file source path
- destination path: file destination path
Returns: nothing
-- Copy autorun.lua into autorun.old
os.cp("/autorun.lua","/autorun.old")
Edits a file.
Arguments:
- file: file path. Can be absolute or relative to current working directory.
Returns: nothing
/> os.edit("autorun.lua")