find_path: Try to find path along the root directory

Description Usage Arguments Details Value Examples

View source: R/path.R

Description

Try to find path under root directory even if the original path is missing

Usage

1
find_path(path, root_dir)

Arguments

path

path to a file. It's fine if the file is missing

root_dir

root directory of the file

Details

When file is absent, find_path concatenates the root directory and path combined to find the file. For example, if the root directory is "~/", and path is "a/b/c/d", the function first seek for existence of "~/a/b/c/d". If failed, then "~/b/c/d", and then "~/c/d" until reaching top (root directory).

Value

The absolute path of file if exists, or NULL if missing/failed.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
## Not run: 
# This example runs when demo (YAB) data are installed

# Case 1: path exists from root directory
find_path('demo/YAB/rave/meta/electrodes.csv',
          root_dir = '~/rave_data/data_dir')

# Case 2: path missing from root directory
find_path('random/folder/not/exists/demo/YAB/rave/meta/electrodes.csv',
          root_dir = '~/rave_data/data_dir')


## End(Not run)

dipterix/raveutils documentation built on July 6, 2020, 12:24 a.m.