Skip to content

posix ​

luau
local posix = require("@std/path/posix")

WARNING

These APIs are still open to future evolution. In new major versions, they may change in backwards incompatible ways.

Summary ​

EntryDescription
Path
Pathlike
basenameReturns the last component of path, or nil if the path has no components.
dirnameReturns the directory portion of path as a string (everything except the last component).
extnameReturns the file extension of path (including the leading dot), or "" if there is none.
formatConverts path to its POSIX string representation.
isAbsoluteReturns true if path is absolute (begins with /).
joinJoins one or more path segments into a single Path. Each segment after the first must be relative.
normalizeReturns a normalized form of path, resolving . and .. components and removing redundant separators.
parseParses path into a structured Path value.
pathmt
pathmt:__tostring
relativeReturns the relative path from from to to. Both paths must be of the same kind (both absolute or both relative).
resolveResolves a sequence of paths into an absolute Path, processing right-to-left and falling back to the current working directory.

Types ​

Path ​

luau
type Path = posixtypes.Path

Pathlike ​

luau
type Pathlike = posixtypes.Pathlike

Functions and Properties ​

posix.basename ​

Returns the last component of path, or nil if the path has no components.

luau
(path: Pathlike) -> string?

posix.dirname ​

Returns the directory portion of path as a string (everything except the last component).

luau
(path: Pathlike) -> string

posix.extname ​

Returns the file extension of path (including the leading dot), or "" if there is none.

luau
(path: Pathlike) -> string

posix.format ​

Converts path to its POSIX string representation.

luau
(path: Pathlike) -> string

posix.isAbsolute ​

Returns true if path is absolute (begins with /).

luau
(path: Pathlike) -> boolean

posix.join ​

Joins one or more path segments into a single Path. Each segment after the first must be relative.

luau
(...: Pathlike) -> Path

posix.normalize ​

Returns a normalized form of path, resolving . and .. components and removing redundant separators.

luau
(path: Pathlike) -> Path

posix.parse ​

Parses path into a structured Path value.

luau
(path: Pathlike) -> Path

posix.pathmt ​

luau
pathinterface.PathInterface

posix.pathmt:__tostring ​

luau
() -> string

posix.relative ​

Returns the relative path from from to to. Both paths must be of the same kind (both absolute or both relative).

luau
(from: Pathlike, to: Pathlike) -> Path

posix.resolve ​

Resolves a sequence of paths into an absolute Path, processing right-to-left and falling back to the current working directory.

luau
(...: Pathlike) -> Path