This works in a vignette searching for a target that could be in the
vignettes directory of its parent package or in the package directory
or in, e.g., one of subdirs = c('extdata', paste('inst', 'extdata', sep=.Platform$file.sep)).
Returns the full path to match(s) if found and a character vector of length
0 if no matches are found. The returned object also has a searched
attribute being a character vector of the directories searched.
This was inspired by a desire to share with others a vignette describing how
to create data objects from a file that could not itself be shared on CRAN.
This is not easy, because the working director available to code in a
vignette changes depending on how that code is run.
path_package2 allows the user to store the target locally, e.g., in
inst/extdata but include it in .gitignore to prevent it from leaving the
local computer. The vignette then decides what to do after calling
path_package2() based on the length of the the object returned.