asRelativePath
fn
auto asRelativePath(CaseSensitive cs = CaseSensitive.osDefault, R1, R2)(R1 path, R2 base) if ((isNarrowString!R1 ||
(isRandomAccessRange!R1 && hasSlicing!R1 && isSomeChar!(ElementType!R1)) &&
!isConvertibleToString!R1) &&
(isNarrowString!R2 ||
(isRandomAccessRange!R2 && hasSlicing!R2 && isSomeChar!(ElementType!R2)) &&
!isConvertibleToString!R2))Transforms path into a path relative to base.
The returned path is relative to base, which is usually the current working directory. base must be an absolute path, and it is always assumed to refer to a directory. If path and base refer to the same directory, the function returns `'.'`.
The following algorithm is used:
- If
pathis a relative directory, return it unaltered. - Find a common root between
pathandbase.If there is no common root, return
pathunaltered. - Prepare a string with as many `../` or `..\` as
necessary to reach the common root from base path.
- Append the remaining segments of
pathto the stringand return.
In the second step, path components are compared using filenameCmp!cs, where cs is an optional template parameter determining whether the comparison is case sensitive or not. See the
Parameters
path | path to transform |
base | absolute path |
cs | whether filespec comparisons are sensitive or not; defaults to CaseSensitive.osDefault |
Returns
a random access range of the transformed path
See Also
fn
auto asRelativePath(CaseSensitive cs = CaseSensitive.osDefault, R1, R2)(auto ref R1 path, auto ref R2 base) if (isConvertibleToString!R1 || isConvertibleToString!R2)No documentation available for this declaration.