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.
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()

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"

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

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

split()

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