Skip to main content
Version: nightly

Types

Url​

Create a URL:

-- regular file
local url = Url("/root/Downloads/logo.png")

-- `/root/dog.jpg` on `my-server` via SFTP
local url = Url("sftp://my-server//root/dog.jpg")

path​

Path portion of the URL.

For the URL sftp://my-server//path/to/file, the path is /path/to/file.

TypePath

name​

Filename of the URL.

Typestring?

stem​

Filename without the extension.

Typestring?

ext​

Extension of the file.

Typestring?

parent​

Parent directory.

TypeSelf?

spec​

Specification of the URL.

TypeSpec

is_absolute​

Whether the path represented by the URL is absolute.

Typeboolean

has_root​

Whether the path represented by the URL has a root.

Typeboolean

join(self, other)​

Join with other to create a new URL.

In/OutType
selfSelf
otherSelf | string
ReturnSelf

starts_with(self, base)​

Whether the URL starts with base.

In/OutType
selfSelf
baseSelf | string
Returnboolean

ends_with(self, base)​

Whether the URL ends with base.

In/OutType
selfSelf
baseSelf | string
Returnboolean

strip_prefix(self, base)​

Strips the prefix of base.

In/OutType
selfSelf
baseSelf | string
ReturnPath

__eq(self, other)​

Whether the URL is equal to other.

In/OutType
selfSelf
otherSelf
Returnboolean

__tostring(self)​

Convert the URL to string.

In/OutType
selfSelf
Returnstring

__concat(self, other)​

Concatenate the URL with other.

In/OutType
selfSelf
otherstring
ReturnSelf

__new(value)​

Make a new URL.

In/OutType
valuestring | Self
ReturnSelf

Path​

Path is the path portion of a Url.

For the URL sftp://my-server//path/to/file, the path is /path/to/file.

name​

Filename of the path.

Typestring?

stem​

Filename without the extension.

Typestring?

parent​

Parent directory.

TypeSelf?

is_absolute​

Whether the path is absolute.

Typeboolean

has_root​

Whether the path has a root.

Typeboolean

join(self, other)​

Join with other to create a new path.

In/OutType
selfSelf
otherSelf | string
ReturnSelf

starts_with(self, base)​

Whether the path starts with base.

In/OutType
selfSelf
baseSelf | string
Returnboolean

ends_with(self, base)​

Whether the path ends with base.

In/OutType
selfSelf
baseSelf | string
Returnboolean

strip_prefix(self, base)​

Strips the prefix of base.

In/OutType
selfSelf
baseSelf | string
ReturnSelf

__eq(self, other)​

Whether the path is equal to other.

In/OutType
selfSelf
otherSelf
Returnboolean

__tostring(self)​

Convert the path to string.

In/OutType
selfSelf
Returnstring

__concat(self, other)​

Concatenate the path with other.

In/OutType
selfSelf
otherstring
ReturnSelf

Spec​

The specification of a Url. Use url.spec to inspect the URL's kind and provider information.

kind​

URL kind.

Typestring

scheme​

URL scheme.

Typestring

domain​

Domain of the URL.

Typestring

is_regular​

Whether the URL represents a regular file.

Typeboolean

Whether the URL is a search result.

Typeboolean

Cha​

One file's characteristics.

is_dir​

Whether the file is a directory.

Typeboolean

is_hidden​

Whether the file is hidden.

Typeboolean

Whether the file is a symlink.

Typeboolean

is_orphan​

Whether the file is a bad symlink, which points to a non-existent file.

Typeboolean

is_dummy​

Whether the file is dummy, which fails to load complete metadata. It could be due to the file system not supporting it, such as FUSE.

Typeboolean

is_block​

Whether the file is a block device.

Typeboolean

is_char​

Whether the file is a character device.

Typeboolean

is_fifo​

Whether the file is a FIFO.

Typeboolean

is_sock​

Whether the file is a socket.

Typeboolean

is_exec​

Whether the file is executable.

Typeboolean

is_sticky​

Whether the file has the sticky bit set.

Typeboolean

len​

Length of the file in bytes.

If you want to get the size of a directory, use size() instead.

Typeinteger

atime​

Accessed time of the file in Unix timestamp.

TypeTime?

btime​

Birth time of the file in Unix timestamp.

TypeTime?

mtime​

Modified time of the file in Unix timestamp.

TypeTime?

uid​

User id of the file.

Typeinteger?
AvailableUnix-like systems only

gid​

Group id of the file.

Typeinteger?
AvailableUnix-like systems only

Number of hard links to the file.

Typeinteger?
AvailableUnix-like systems only

perm(self)​

Unix permission representation, such as drwxr-xr-x.

Typestring?
AvailableUnix-like systems only

File​

A bare file without any context information. See also fs::File.

url​

URL of the file.

TypeUrl

cha​

Cha of the file.

TypeCha

Path of the file points to, if it's a symlink.

TypePath?

name​

Name of the file.

Typestring

Icon​

An icon.

text​

Text of the icon.

Typestring

style​

Style of the icon.

TypeStyle

Error​

An error.

code​

Raw error code.

Typeinteger

__tostring(self)​

Convert the error to string.

In/OutType
selfSelf
Returnstring

__concat(self, other)​

Concatenate the error with other.

In/OutType
selfSelf
otherstring
ReturnError

Window​

rows​

Number of rows.

Typeinteger

cols​

Number of columns.

Typeinteger

width​

Width in pixels.

Typeinteger

height​

Height in pixels.

Typeinteger