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.
| Type | Path |
name
Filename of the URL.
| Type | string? |
stem
Filename without the extension.
| Type | string? |
ext
Extension of the file.
| Type | string? |
parent
Parent directory.
| Type | Self? |
domain
Domain of the URL.
For the URL sftp://my-server//root/dog.jpg, the domain is my-server.
| Type | string? |
is_regular
Whether the file represented by the URL is a regular file.
| Type | boolean |
is_search
Whether the file represented by the URL is from a search result.
| Type | boolean |
is_archive
Whether the file represented by the URL is from an archive.
| Type | boolean |
is_absolute
Whether the path represented by the URL is absolute.
| Type | boolean |
has_root
Whether the path represented by the URL has a root.
| Type | boolean |
join(self, other)
Join with other to create a new URL.
| In/Out | Type |
|---|---|
self | Self |
other | Self | string |
| Return | Self |
starts_with(self, base)
Whether the URL starts with base.
| In/Out | Type |
|---|---|
self | Self |
base | Self | string |
| Return | boolean |
ends_with(self, base)
Whether the URL ends with base.
| In/Out | Type |
|---|---|
self | Self |
base | Self | string |
| Return | boolean |
strip_prefix(self, base)
Strips the prefix of base.
| In/Out | Type |
|---|---|
self | Self |
base | Self | string |
| Return | Path |
__eq(self, other)
Whether the URL is equal to other.
| In/Out | Type |
|---|---|
self | Self |
other | Self |
| Return | boolean |
__tostring(self)
Convert the URL to string.
| In/Out | Type |
|---|---|
self | Self |
| Return | string |
__concat(self, other)
Concatenate the URL with other.
| In/Out | Type |
|---|---|
self | Self |
other | string |
| Return | Self |
__new(value)
Make a new URL.
| In/Out | Type |
|---|---|
value | string | Self |
| Return | Self |
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.
| Type | string? |
stem
Filename without the extension.
| Type | string? |
parent
Parent directory.
| Type | Self? |
is_absolute
Whether the path is absolute.
| Type | boolean |
has_root
Whether the path has a root.
| Type | boolean |
join(self, other)
Join with other to create a new path.
| In/Out | Type |
|---|---|
self | Self |
other | Self | string |
| Return | Self |
starts_with(self, base)
Whether the path starts with base.
| In/Out | Type |
|---|---|
self | Self |
base | Self | string |
| Return | boolean |
ends_with(self, base)
Whether the path ends with base.
| In/Out | Type |
|---|---|
self | Self |
base | Self | string |
| Return | boolean |
strip_prefix(self, base)
Strips the prefix of base.
| In/Out | Type |
|---|---|
self | Self |
base | Self | string |
| Return | Self |
__eq(self, other)
Whether the path is equal to other.
| In/Out | Type |
|---|---|
self | Self |
other | Self |
| Return | boolean |
__tostring(self)
Convert the path to string.
| In/Out | Type |
|---|---|
self | Self |
| Return | string |
__concat(self, other)
Concatenate the path with other.
| In/Out | Type |
|---|---|
self | Self |
other | string |
| Return | Self |
Cha
One file's characteristics.
is_dir
Whether the file is a directory.
| Type | boolean |
is_hidden
Whether the file is hidden.
| Type | boolean |
is_link
Whether the file is a symlink.
| Type | boolean |
is_orphan
Whether the file is a bad symlink, which points to a non-existent file.
| Type | boolean |
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.
| Type | boolean |
is_block
Whether the file is a block device.
| Type | boolean |
is_char
Whether the file is a character device.
| Type | boolean |
is_fifo
Whether the file is a FIFO.
| Type | boolean |
is_sock
Whether the file is a socket.
| Type | boolean |
is_exec
Whether the file is executable.
| Type | boolean |
is_sticky
Whether the file has the sticky bit set.
| Type | boolean |
len
Length of the file in bytes.
If you want to get the size of a directory, use size() instead.
| Type | integer |
atime
Accessed time of the file in Unix timestamp.
| Type | integer? |
btime
Birth time of the file in Unix timestamp.
| Type | integer? |
mtime
Modified time of the file in Unix timestamp.
| Type | integer? |
uid
User id of the file.
| Type | integer? |
| Available | Unix-like systems only |
gid
Group id of the file.
| Type | integer? |
| Available | Unix-like systems only |
nlink
Number of hard links to the file.
| Type | integer? |
| Available | Unix-like systems only |
perm(self)
Unix permission representation, such as drwxr-xr-x.
| Type | string? |
| Available | Unix-like systems only |
File
A bare file without any context information. See also fs::File.
url
URL of the file.
| Type | Url |
cha
Cha of the file.
| Type | Cha |
link_to
Path of the file points to, if it's a symlink.
| Type | Path? |
name
Name of the file.
| Type | string |
Icon
An icon.
text
Text of the icon.
| Type | string |
style
Style of the icon.
| Type | Style |
Error
An error.
code
Raw error code.
| Type | integer |
__tostring(self)
Convert the error to string.
| In/Out | Type |
|---|---|
self | Self |
| Return | string |
__concat(self, other)
Concatenate the error with other.
| In/Out | Type |
|---|---|
self | Self |
other | string |
| Return | Error |
Window
rows
Number of rows.
| Type | integer |
cols
Number of columns.
| Type | integer |
width
Width in pixels.
| Type | integer |
height
Height in pixels.
| Type | integer |