Skip to main content

Resolve symbolic links in a path (file.path.resolve_symlinks)

Declaration​

resolved_path, err = file.path.resolve_symlinks(path)

Parameters​

  • path
    String. The original path string containing symbolic links.

Returns​

  • resolved_path
    String or nil. Returns the path string with symbolic links resolved and the path normalized on success, or nil if the path string is invalid.
  • err
    String. Returns "Invalid path" if the path is invalid.

Description​

Resolve symbolic links in the path and normalize the resulting path. The result depends on the actual symbolic links on the device.
Returning a path string does not mean the path necessarily exists. If the path does not exist or contains parts that cannot be resolved, nil or an error message is not guaranteed. To check whether it exists, use file.exists.
This function is available only in versions released after 20250914.

Example​

-- Assume /var/mobile/link is a symbolic link to /var/mobile/Documents
local real_path = file.path.resolve_symlinks("/var/mobile/link/script.lua")
-- Returns "/var/mobile/Documents/script.lua"