Namespace: path

pc.path

File path API
Source:

Members

(static) delimiter

The character that separates path segments
Source:

Methods

(static) getBasename(path) → {String}

Return the basename of the path. That is the second element of the pair returned by passing path into pc.path.split.
Parameters:
Name Type Description
path String The path to process.
Source:
Returns:
The basename.
Type
String
Example
pc.path.getBasename("/path/to/file.txt"); // returns "path.txt"
pc.path.getBasename("/path/to/dir"); // returns "dir"

(static) getDirectory(path) → {String}

Get the directory name from the path. This is everything up to the final instance of pc.path.delimiter.
Parameters:
Name Type Description
path String The path to get the directory from
Source:
Returns:
The directory part of the path.
Type
String

(static) join(one, two) → {String}

Join two sections of file path together, insert a delimiter if needed.
Parameters:
Name Type Description
one String First part of path to join.
two String Second part of path to join.
Source:
Returns:
The joined file path.
Type
String

(static) normalize(path) → {String}

Normalize the path by removing '.' and '..' instances
Parameters:
Name Type Description
path String The path to normalize
Source:
Returns:
The normalized path
Type
String

(static) split(path) → {Array}

Split the pathname path into a pair [head, tail] where tail is the final part of the path after the last delimiter and head is everything leading up to that. tail will never contain a slash
Parameters:
Name Type Description
path String The path to split.
Source:
Returns:
The split path which is an array of two strings, the path and the filename.
Type
Array