Skip to main content

Update access and modification time (file.touch)

Declaration

ok, err = file.touch(path [, atime , mtime])

Parameters

  • path
    String.
  • atime
    Integer, optional. Seconds timestamp. If not specified, uses os.time().
  • mtime
    Integer, optional. Seconds timestamp. If not specified, uses atime.

Returns

  • ok
    Boolean. true if success, false if failure.
  • err
    String. Error message when operation fails.

Notes

Update access and modification time. Equivalent to lfs.touch.
Available in versions after 2025-07-05.

Example

local success, err = file.touch("/var/mobile/Media/1ferver/lua/scripts/", os.time() - 86400 * 3, os.time() - 86400 * 2)
if success then
sys.alert("Updated successfully")
else
sys.alert("Update failed: "..err)
end

Note: Uses sys.alert