API Reference

Class List

pc.path

File path API

Summary

Static Properties

delimiterThe character that separates path segments

Static Methods

getBasenameReturn the basename of the path.
getDirectoryGet the directory name from the path.
joinJoin two sections of file path together, insert a delimiter if needed.
normalizeNormalize the path by removing '.
splitSplit 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.

Details

Static Properties

delimiterThe character that separates path segments

Static Methods

getBasename(path)

Return the basename of the path. That is the second element of the pair returned by passing path into pc.path.split.

pc.path.getBasename("/path/to/file.txt"); // returns "path.txt"
pc.path.getBasename("/path/to/dir"); // returns "dir"

Parameters

pathStringThe path to process.

Returns

String The basename.

getDirectory(path)

Get the directory name from the path. This is everything up to the final instance of pc.path.delimiter.

Parameters

pathStringThe path to get the directory from

Returns

String The directory part of the path.

join(one, two)

Join two sections of file path together, insert a delimiter if needed.

Parameters

oneStringFirst part of path to join.
twoStringSecond part of path to join.

Returns

String The joined file path.

normalize(path)

Normalize the path by removing '.' and '..' instances

Parameters

pathStringThe path to normalize

Returns

String The normalized path

split(path)

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

pathStringThe path to split.

Returns

Array The split path which is an array of two strings, the path and the filename.