Get current working directory (file.currentdir)
Declaration
cwd, err = file.currentdir()
Returns
- cwd
String. Returns the directory path on success; nil on failure. - err
String. Error message when operation fails.
Notes
Get current working directory. Equivalent to lfs.currentdir.
Available in versions after 2025-07-05.
Example
local cwd, err = file.currentdir()
if cwd then
sys.alert("Current working directory: "..cwd)
else
sys.alert("Failed to get current working directory: "..err)
end
Note: Uses sys.alert