string or slicable random access range
bidirectional range of slices of path
import std.algorithm.comparison : equal; import std.conv : to; assert(equal(pathSplitter("/"), ["/"])); assert(equal(pathSplitter("/foo/bar"), ["/", "foo", "bar"])); assert(equal(pathSplitter("foo/../bar//./"), ["foo", "..", "bar", "."])); version (Posix) { assert(equal(pathSplitter("//foo/bar"), ["/", "foo", "bar"])); } version (Windows) { assert(equal(pathSplitter(`foo\..\bar\/.\`), ["foo", "..", "bar", "."])); assert(equal(pathSplitter("c:"), ["c:"])); assert(equal(pathSplitter(`c:\foo\bar`), [`c:\`, "foo", "bar"])); assert(equal(pathSplitter(`c:foo\bar`), ["c:foo", "bar"])); }
Slice up a path into its elements.