vibe.d beta banner
get vibe.d

Asynchronous I/O that doesn’t get in your way, written in D

Function GenericPath.normalize

Removes any redundant path segments and replaces all separators by the default one.

void normalize();

The resulting path representation is suitable for basic semantic comparison to other normalized paths.

Note that there are still ways for different normalized paths to represent the same file. Examples of this are the tilde shortcut to the home directory on Unix and Linux operating systems, symbolic or hard links, and possibly environment variables are examples of this.


Throws an Exception if an absolute path contains parent directory segments ("..") that lead to a path that is a parent path of the root path.


auto path = WindowsPath("C:\\test/foo/./bar///../baz");
assert(path.toString() == "C:\\test\\foo\\baz", path.toString());

path = WindowsPath("foo/../../bar/");
assert(path.toString() == "..\\bar\\");

/// Returns the string representation of the path.
string toString() const nothrow @nogc { return m_path; 

Sönke Ludwig


© 2012-2021 Sönke Ludwig


Subject to the terms of the MIT license, as written in the included LICENSE.txt file.