path_normalize(path, @optional allow_relative, origin_directory)
Take a path
of a file or directory and returns its normalized path. The optional origin_directory
parameter,
which defaults to the current working directory, is the directory used to resolve relative paths. All components of the paths path
and origin_directory
must exist, except possibly the last component of path
. A normalized path is a path
containing no redundant parts and which is consistent with the current structure of the filesystem. A normalized path of a directory
will always end with a path separator (i.e. '/', '\', or ':' depending on the operating system). The optional allow_relative
parameter, which defaults to false
, indicates if the path returned can be expressed relatively
to origin_directory
: a false
requests an absolute path, the symbol
'shortest
requests the shortest of the absolute and relative paths, and any other value
requests the relative path. The shortest path is useful for interaction with the user because short relative paths are
typically easier to read than long absolute paths.
path_normalize("../hello.txt")
// /users/me/projects/hello.txt