Macro for constructing boolean check for valid path
cmd_install_is_valid(path_search, util = NULL)
path_search | function output of |
---|---|
util | value to pass to |
a function returning TRUE or FALSE if a valid install is detected.
With arguments: path
(a path to install location), util
an optional character(1)
to
if (.Platform$OS.type == "unix") { search <- cmd_path_search(option_name = "bin_path", default_path = "/bin/") valid_install <- cmd_install_is_valid(search) # Returns TRUE if "/bin/" exists valid_install() # Returns FALSE if "bad/path/" doesn't exist valid_install("bad/path/") # Also works with options search_option_only <- cmd_path_search(option_name = "bin_path") valid_install2 <- cmd_install_is_valid(search_option_only) options(bin_path = "/bin/") valid_install2() # Setting util = TRUE will check that all utils are also installed search_with_utils <- cmd_path_search(default_path = "/bin", utils = c("ls", "pwd")) valid_install_all <- cmd_install_is_valid(search_with_utils, util = TRUE) valid_install_all() }#> [1] TRUE