Comment on page
Path
The functions for manipulating filename paths are described here.
The AbsPath function returns an absolute representation of path.
The BaseName function returns the last element of path. Trailing path separators are removed before extracting the last element. If the path is empty, the function returns ".".
The Dir function returns all but the last element of path, typically the path's directory.
The Ext function returns the file name extension. The result extension is without a dot.
The JoinPath function joins any number of path elements into a single path, adding a separator if necessary.
The MatchPath function checks if the given name matches the specified pattern. The function checks the pattern completely for the specified path, not for the substring. You can use a regular expression as a pattern. To do this, add a / at the beginning and end.
- '*' - matches any sequence of non-separator characters
- '?' - matches any single non-separator character
MatchPath(`*.txt`, `myfile.txt`) // true
MatchPath(`?a?.pdf`, `1ab.pdf`) // true
MatchPath(`/home/ak/my.pdf`, `*.pdf`) // false
MatchPath(`/home/ak/my.pdf`, `/home/*/my.*`) // true
MatchPath(`/home/ak/my.pdf`, `/home/*/my.*`) // true
MatchPath(`/user/`, `/home/user/myfile`) // true
The Path function concatenates the Name and Dir fields of the finfo variable and returns the resulting path.
Last modified 2yr ago