← Standard library

Path

static class Path
import Path from Wax;

Pure string operations for file paths. Uses / as the separator and does not access the filesystem. Methods that return slices retain a view into their source string; use ToString() when a separate string is needed.

Path.wax:5

Inherits from object. Follow these links for inherited members.

Members

Separatorconst

const uint8 Separator = 47

The / byte recognized as a separator. Backslashes are not normalized.

Path.wax:10

Dotconst

const uint8 Dot = 46

The . byte used to find the final extension.

Path.wax:14

LastSeparatorIndexmethod

public static fn LastSeparatorIndex(string path) : int32

Returns the byte offset of the final slash, or -1 if absent. Backslashes are not separators.

Path.wax:19

LastDotIndexmethod

public static fn LastDotIndex(string path, int32 afterIndex) : int32

Returns the byte offset of the final dot strictly after afterIndex, or -1 if absent. Pass the last separator index to restrict the search to a file name.

Path.wax:34

GetFileNamemethod

public static fn GetFileName(string path) : StringSlice

Borrows the part after the final /, or the entire path if no separator exists. A trailing separator produces an empty name.

Path.wax:49

GetExtensionmethod

public static fn GetExtension(string path) : StringSlice

Borrows from the final . after the last separator through the end, including the dot. No dot yields an empty slice; a leading dot in a file name counts as an extension.

Path.wax:61

GetFileNameWithoutExtensionmethod

public static fn GetFileNameWithoutExtension(string path) : StringSlice

Borrows the file name up to its final dot. A dot-only prefix such as .env can therefore have an empty name before its extension.

Path.wax:74

GetDirectoryNamemethod

public static fn GetDirectoryName(string path) : StringSlice

Borrows the prefix before the final /, excluding that separator. No separator, or a separator only at byte zero, produces an empty slice.

Path.wax:86

HasExtensionmethod

public static fn HasExtension(string path) : bool

Tests whether a dot occurs after the last separator, including leading or trailing dots in the file name.

Path.wax:98

ChangeExtensionmethod

public static fn ChangeExtension(string path, string newExt) : string

Replaces the final extension with newExt verbatim. Include the leading dot yourself when desired; an empty replacement removes the extension.

Path.wax:108

Joinmethod

public static fn Join(string a, string b) : string

Joins two path strings with one separator at their boundary, dropping one of two touching slashes. Does not normalize other separators, resolve dot segments, or treat a leading slash in the second string as a replacement root.

Path.wax:123