Skip to main content

Get symlink attributes (file.lattrs)

Declaration

attrs, err = file.lattrs(path [, request])

Parameters

  • path
    String.
  • request
    Table or String, optional.
    • If a table is provided, the function fills this table with results instead of creating a new one.
    • If a string is provided, returns only the specified field.
    • When not specified, returns a table with all fields.
    • "dev": device where the inode resides
    • "ino": inode number
    • "mode": file type, one of "file", "directory", "link", "socket", "named pipe", "char device", "block device" or "other"
    • "nlink": hard link count
    • "uid": owner user id
    • "gid": owner group id
    • "rdev": device type for special files
    • "access": last access time
    • "modification": last modification time
    • "change": last status change time
    • "size": file size in bytes
    • "permissions": file permissions
    • "blksize": optimal I/O block size
    • "blocks": number of 512-byte blocks allocated
    • "target": symlink target path

Returns

  • attrs
    Table or nil. Attributes table on success; nil on failure.
  • err
    String. Error message when operation fails.

Notes

Get attributes of a path. If the path is a symbolic link, returns the information of the link itself. Equivalent to lfs.symlinkattributes.
Available in versions after 2025-07-05.

Example

local info, err = file.lattrs("/var/mobile/Media/1ferver/lua/scripts/")
if info then
sys.alert("File info: "..json.encode(info))
else
sys.alert("Get attributes failed: "..err)
end

Note: Uses sys.alert