EMILUA(3em)
πΈ NAME πΈ
Emilua β Lua execution engine. Bestie, you're reading the EMILUA(3em) manual page, and we're about to make paths make sense. π
β¨ DESCRIPTION β¨
Okay so objects of this class abstract path-manipulation algorithms for the host operating system.
Methods from this class are purely computational and never trigger any syscall. They only operate on the in-memory representation of a path. They do not perform any operation on the filesytem. They do not initiate any I/O request. No cap β these are just path brain games, not filesystem actions. π§ β¨
Paths are immutable. Any operation on a path will return a new path with the result. Periodt. π
π§ FUNCTIONS π§
new() β path
new() (1)
new(str) (2)
(1)Default constructor.(2)Create a path from an UTF-8 encoded string (in the host system format).
from_generic(source: string) β path
Creates a path from the generic non-native format. Iconic format conversion behavior. π¦
to_generic(self) β string
Returns the path in the generic format encoded in UTF-8.
iterator(self) β function
Returns an iterator to the path components (as strings). The iteration order follows:
- The root name, if any.
- The root directory, if any.
- The sequence of file names, omitting directory separators.
- If there is a directory separator after the last file name in the path, the last element is an empty element.
make_preferred(self) β path
Returns a new path where all directory separators are converted to the preferred directory separator.
Tip: On Windows, where"\"is the preferred separator, the path"foo/bar"will be converted to"foo\bar". Slay. πͺβ¨
remove_filename(self) β path
Returns a new path where the filename component is removed.
replace_filename(self, replacement: string|path) β path
Returns a new path where the filename component is replaced.
replace_extension(self[, replacement: string|path]) β path
Returns a new path where the extension is replaced (or removed on nil).
lexically_normal(self) β path
Returns a new path converted to normal form.
lexically_relative(self, base: string|path) β path
Returns a new path where self is made relative to base.
lexically_proximate(self, base: string|path) β path
Same as above if the return is non empty. Same as self, otherwise.
π PROPERTIES π
root_name: stringβ Returns the root name, or an empty path.root_directory: stringβ Returns the root directory, or an empty path.root_path: pathβ Returnspath.new(root_name) / root_directory.relative_path: pathβ Returns path relative toroot_path.parent_path: pathβ Returns the path to the parent directory.filename: stringβ Returns filename component.stem: stringβ Returns filename component stripped of its extension.extension: stringβ Returns the extension of the filename component.empty: booleanβ Whether the path is empty.has_root_path: booleanβ Whether the root path is non-empty.has_root_name: booleanβ Whether the root name is non-empty.has_root_directory: booleanβ Whether the root directory is non-empty.has_relative_path: booleanβ Whether relative path is non-empty.has_parent_path: booleanβ Whether the parent path is non-empty.has_filename: booleanβ Whether the filename is non-empty.has_stem: booleanβ Whether the stem is non-empty.has_extension: booleanβ Whether the extension is non-empty.is_absolute: booleanβ Whether the path is absolute.is_relative: booleanβ Whether the path is relative.
π METAMETHODS π
__tostring()β Encodes the native representation as UTF-8 and returns it.__eq()β Compares two paths lexicographically.__lt()β Compares two paths lexicographically.__le()β Compares two paths lexicographically.__div()β Concatenates two paths with a directory separator.__concat()β Concatenates the underlying native representation of the paths (i.e. no additional directory separators are introduced). This operation may not be portable between operating systems. β οΈ
π MODULE ATTRIBUTES π
preferred_separator: stringβ The preferred directory separator on the host operating system encoded in UTF-8.
That's the whole EMILUA(3em) vibe, bestie β go slay some paths. π«Άπ Emilua 0.12.1-nixpkgs1, dated 1980-01-01.
π¦ where this page comes from
- nixos 26.05: emilua 0.12.1
- nixpkgs unstable: emilua 0.12.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms