Find resources within a director project.

director_find(pattern = "", method = "wildcard", base = "",
  by_mtime = TRUE)

Arguments

pattern

character. The resources to search for. The default is "", which will list all resources within the base.

method

character. The search method. The available options are "wildcard", code"substring", or "exact". See the function description for the full explanation of these methods. The default is "wildcard".

base

character. A prefix under which to look for. For example, if base = "subdir", then only resources under the "subdir" directory (relative to the director root) will be returned. The default is "", which will list all resources within the director root.

by_mtime

logical. Whether or not to sort results by modification time in descending order. The default is TRUE, so that the first result is the most recently modified resource.

Value

a character vector of matched resources.

Note

The available search methods are:

wildcard

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.

partial

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.

exact

The exact name of the resource. In this mode, either a single string (the resource name itself) or character(0) will be returned.

Examples

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') # "" })