Test if a path is a subpath of a dir
Check if the path starts with the dir path.
is_sub_path(x, dir, n = nchar(dir))
x |
A vector of paths. |
dir |
A vector of directory paths. |
n |
The length of |
A logical vector.
You may want to normalize the values of the x
and dir
arguments first (with xfun::normalize_path()
), to make sure
the path separators are consistent.
xfun::is_sub_path("a/b/c.txt", "a/b") # TRUE xfun::is_sub_path("a/b/c.txt", "d/b") # FALSE xfun::is_sub_path("a/b/c.txt", "a\\b") # FALSE (even on Windows)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.