asRelativePath

fnauto 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:

  1. If path is a relative directory, return it unaltered.
  2. Find a common root between path and base.

    If there is no common root, return path unaltered.

  3. Prepare a string with as many `../` or `..\` as

    necessary to reach the common root from base path.

  4. Append the remaining segments of path to the string

    and 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

filenameCmp documentation for details.

Parameters

pathpath to transform
baseabsolute path
cswhether filespec comparisons are sensitive or not; defaults to CaseSensitive.osDefault

Returns

a random access range of the transformed path

See Also

fnauto 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.