getRelativePath.Rd
Gets the relative pathname relative to a directory.
# S3 method for default
getRelativePath(pathname, relativeTo=getwd(), caseSensitive=NULL, ...)
Returns a character
string of the relative pathname.
If caseSensitive == NULL
, the relative path is used to decide if
the comparison should be done in a case-sensitive mode or not.
The current check is if it is a Windows path or not, that is, if
the relative path starts with a device letter, then the comparison
is non-case sensitive.
In case the two paths are on different file systems, for instance,
C:/foo/bar/ and D:/foo/, the method returns pathname
as is.
getRelativePath("foo", "foo") # "."
#> [1] "."
getRelativePath("foo/bar", "foo") # "bar"
#> [1] "bar"
getRelativePath("foo/bar", "foo/bar/yah") # ".."
#> [1] ".."
getRelativePath("foo/bar/cool", "foo/bar/yah/sub/") # "../../cool"
#> [1] "../../cool"
getRelativePath("/tmp/bar/", "/bar/foo/") # "../../tmp/bar"
#> [1] "../../tmp/bar"
# Windows
getRelativePath("C:/foo/bar/", "C:/bar/") # "../foo/bar"
#> [1] "../foo/bar"
getRelativePath("C:/foo/bar/", "D:/bar/") # "C:/foo/bar"
#> [1] "C:/foo/bar"