| 1 |
% Generated by roxygen2: do not edit by hand |
| 2 |
% Please edit documentation in R/paths.R |
| 3 |
\name{is_sub_path} |
| 4 |
\alias{is_sub_path} |
| 5 |
\title{Test if a path is a subpath of a dir} |
| 6 |
\usage{ |
| 7 |
is_sub_path(x, dir, n = nchar(dir)) |
| 8 |
} |
| 9 |
\arguments{ |
| 10 |
\item{x}{A vector of paths.} |
| 11 |
|
| 12 |
\item{dir}{A vector of directory paths.} |
| 13 |
|
| 14 |
\item{n}{The length of \code{dir} paths.} |
| 15 |
} |
| 16 |
\value{ |
| 17 |
A logical vector. |
| 18 |
} |
| 19 |
\description{ |
| 20 |
Check if the path starts with the dir path. |
| 21 |
} |
| 22 |
\note{ |
| 23 |
You may want to normalize the values of the \code{x} and \code{dir} arguments |
| 24 |
first (with \code{\link[=normalize_path]{normalize_path()}}), to make sure the path separators |
| 25 |
are consistent. |
| 26 |
} |
| 27 |
\examples{ |
| 28 |
xfun::is_sub_path("a/b/c.txt", "a/b") # TRUE |
| 29 |
xfun::is_sub_path("a/b/c.txt", "d/b") # FALSE |
| 30 |
xfun::is_sub_path("a/b/c.txt", "a\\\\b") # FALSE (even on Windows) |
| 31 |
} |