first_accessible_path: Find the first accessible file path from a vector of paths.

View source: R/path_utils.R

first_accessible_pathR Documentation

Find the first accessible file path from a vector of paths.

Description

This function is useful for finding a file that may be in one of several different locations.

Usage

first_accessible_path(paths, mode = 0)

Arguments

paths

"A character vector of paths to check for accessibility, in order."

mode

"Has the same meaning as in file.access()."

Value

The first element of paths for which file.access() returns TRUE. If none of paths is accessible, NA is returned.

Examples

exec_paths <- strsplit(Sys.getenv("PATH"), ":")[[1]]
first_accessible_path(exec_paths)

DarwinAwardWinner/rctutils documentation built on July 22, 2022, 5:19 a.m.