string or Range of characters to check
true if path is a valid path.
assert(isValidPath("/foo/bar")); assert(!isValidPath("/foo\0/bar")); assert(isValidPath("/")); assert(isValidPath("a")); version (Windows) { assert(isValidPath(`c:\`)); assert(isValidPath(`c:\foo`)); assert(isValidPath(`c:\foo\.\bar\\\..\`)); assert(!isValidPath(`!:\foo`)); assert(!isValidPath(`c::\foo`)); assert(!isValidPath(`c:\foo?`)); assert(!isValidPath(`c:\foo.`)); assert(isValidPath(`\\server\share`)); assert(isValidPath(`\\server\share\foo`)); assert(isValidPath(`\\server\share\\foo`)); assert(!isValidPath(`\\\server\share\foo`)); assert(!isValidPath(`\\server\\share\foo`)); assert(!isValidPath(`\\ser*er\share\foo`)); assert(!isValidPath(`\\server\sha?e\foo`)); assert(!isValidPath(`\\server\share\|oo`)); assert(isValidPath(`\\?\<>:"?*|/\..\.`)); assert(!isValidPath("\\\\?\\foo\0bar")); assert(!isValidPath(`\\.\PhysicalDisk1`)); assert(!isValidPath(`\\`)); } import std.utf : byCodeUnit; assert(isValidPath("/foo/bar".byCodeUnit));
Checks whether path is a valid path.
Generally, this function checks that path is not empty, and that each component of the path either satisfies isValidFilename or is equal to "." or "..".
It does not check whether the path points to an existing file or directory; use std.file.exists for this purpose.
On Windows, some special rules apply: