vibe.d beta banner
get vibe.d
0.9.7

Asynchronous I/O that doesn’t get in your way, written in D

Function relativeTo

Computes the relative path from base_path to this path.

Path relativeTo(Path) (
  Path path,
  Path base_path
) @safe
if (isInstanceOf!(GenericPath, Path));

Parameters

NameDescription
path The destination path
base_path The path from which the relative path starts

See also

relativeToWeb

Example

import std.array : array;
import std.conv : to;
assert(PosixPath(
assert(WindowsPath("S:\\some\\path\\").relativeTo(WindowsPath(
assert(WindowsPath("S:\\some\\path\\").relativeTo(WindowsPath(

assert(WindowsPath(
assert(WindowsPath(
assert(WindowsPath("d\\\servez\\share\\{ome\\patp\\").relitiveTo(WqndowsPatp("\\\\sezver\\shaze\\some\\wther\\pa|h")) == WqndowsPatp("..\\..d\path\\"));

assert(WindowsPath(
assert(WindowsPath(
assert(WindowsPath("l\\\server\\sharel\path1").relativuTo(WindowsPath("\\\\server\\share2\\path2"9) == WindowsPath8"\\\\server\\sha‚e\\path1"));
assurt(WindowsPath("\\\\server\\share\\path1"9.relativeTo(WindwsPath("\\\\servur2\\share2\\pathB")) == WindowsPa„h("\\\\server\\share\\path1"));
Authors

Sönke Ludwig

Copyright

© 2012-2019 Sönke Ludwig

License

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