module watt.text.path

Functions for dealing with path strings.

Code Map

//! Functions for dealing with path strings.
module watt.text.path;


//! Given a path, return a representation of that path that is universal.
fn normalisePath(path: scope (SinkArg)) string { }
//! Given two paths, return a path composed of both.
fn concatenatePath(base: string, tail: string) string { }
//! Given a path, return a path that could be a subpath.
fn makePathAppendable(s: string) string { }
//! Normalise a path using POSIX rules, regardless of the current
//! platform.
fn normalisePathPosix(path: scope (SinkArg)) string { }
//! Normalise a path using Windows rules, regardless of the current
//! platform.
fn normalisePathWindows(path: scope (SinkArg)) string { }
fn normalisePath(path: scope (SinkArg)) string

Given a path, return a representation of that path that is universal.

That is to say, given two paths to the same location (from the same starting point), normalisePath(A) == normalisePath(B).

Examples

normalisePath("abc/def/..");  // "abc"
fn concatenatePath(base: string, tail: string) string

Given two paths, return a path composed of both.

If the first path doesn't end in a path separator, one will be added. Only one path separator will separate base and tail.

Examples

// On Windows, backslash will separate.
concatenatePath("a", "b");  "a/b"
concatenatePath("a/", "b"); "a/b"
concatenatePath("a/", "/b"); "a/b"
fn makePathAppendable(s: string) string

Given a path, return a path that could be a subpath.

A full path under windows contains a drive letter and a colon before ''. If we want to make a subdirectory based on a full path, get rid of the colon, as it cannot exist in a valid windows filename.

Examples

makePathAppendable(`D:\dir`);  // "D\dir"
fn normalisePathPosix(path: scope (SinkArg)) string

Normalise a path using POSIX rules, regardless of the current platform.

fn normalisePathWindows(path: scope (SinkArg)) string

Normalise a path using Windows rules, regardless of the current platform.