Find resources within a director project.
director_find(pattern = "", method = "wildcard", base = "", by_mtime = TRUE)
pattern | character. The resources to search for. The default is
|
---|---|
method | character. The search method. The available options
are |
base | character. A prefix under which to look for. For example,
if |
by_mtime | logical. Whether or not to sort results by modification time
in descending order. The default is |
a character vector of matched resources.
The available search methods are:
Similar to Sublime or vim's ctrl + P, this method
of search will look for consecutive appearances of characters.
For example, if we have a resource "some_resource"
, then
looking for "so"
, "sre"
or even "smsrc"
will
return a match, since those characters occur consecutively in the
original resource name.
This method will try to find a substring that
matches the resource name. For example, if we have
"dir/some_resource"
, then looking for "dir/some"
will
return a match.
The exact name of the resource. In this mode, either a
single string (the resource name itself) or character(0)
will
be returned.
not_run({ # Imagine we have a file structure: # - foo # - one # - one.R # - helper.R # - two.R # # Then the bellow will return \code{"foo/one"}, \code{"two"}, and \code{""}, # respectively. Note that the \code{"helper.R"} file is not considered a # resource by the director as \code{"one.R"} shares its name with its # parent directory and is considered the accessible resource. d <- director('foo') d$find('fone', method = 'wildcard') # "foo/one" # Under the hood, this looks for the regex .*f.*o.*n.*e.* d$find('wo', method = 'partial') # "two" d$find('none', method = 'exact') # "" })