relativeTo

fun relativeTo(path: Path): Path(source)

Returns a relative path representing this path, but relative to path. Note that path will be converted to an absolute path when it isn't one.

In other words, if relPath1 = path1.relativeTo(path2), then path2.resolve(relPath1) == path1.