Path
static class Pathimport 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.
Inherits from object. Follow these links for inherited members.
Members
Separatorconst
const uint8 Separator = 47The / byte recognized as a separator. Backslashes are not normalized.
Dotconst
const uint8 Dot = 46The . byte used to find the final extension.
LastSeparatorIndexmethod
public static fn LastSeparatorIndex(string path) : int32Returns the byte offset of the final slash, or -1 if absent. Backslashes are not separators.
LastDotIndexmethod
public static fn LastDotIndex(string path, int32 afterIndex) : int32Returns 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.
GetFileNamemethod
public static fn GetFileName(string path) : StringSliceBorrows the part after the final /, or the entire path if no separator exists. A trailing
separator produces an empty name.
GetExtensionmethod
public static fn GetExtension(string path) : StringSliceBorrows 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.
GetFileNameWithoutExtensionmethod
public static fn GetFileNameWithoutExtension(string path) : StringSliceBorrows the file name up to its final dot. A dot-only prefix such as .env can therefore
have an empty name before its extension.
GetDirectoryNamemethod
public static fn GetDirectoryName(string path) : StringSliceBorrows the prefix before the final /, excluding that separator. No separator, or a
separator only at byte zero, produces an empty slice.
HasExtensionmethod
public static fn HasExtension(string path) : boolTests whether a dot occurs after the last separator, including leading or trailing dots in the file name.
ChangeExtensionmethod
public static fn ChangeExtension(string path, string newExt) : stringReplaces the final extension with newExt verbatim. Include the leading dot yourself when
desired; an empty replacement removes the extension.
Joinmethod
public static fn Join(string a, string b) : stringJoins 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.