-
Notifications
You must be signed in to change notification settings - Fork 231
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.
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. A file or directory can be removed with Lua [os.remove()] (http://www.lua.org/manual/5.3/manual.html#6.9) standard function.
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
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")