vibe.d beta banner
get vibe.d
0.10.1

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

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.

Example

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

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

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

Sönke Ludwig

Copyright

© 2012-2018 Sönke Ludwig

License

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