powered by
Assert that all filepaths supplied have one of the selected extensions. Does not require file to actually exist.
assert_all_files_have_extension( x, extensions, compression = FALSE, msg = NULL, call = rlang::caller_env(), arg_name = NULL )
invisible(TRUE) if x has any of the specified extensions, otherwise aborts with the error message specified by msg
x
msg
An object
valid extensions (character vector). Do not include the '.', e.g. supply extensions = 'txt' not extensions = '.txt'
extensions = 'txt'
extensions = '.txt'
should compression extension ‘.gz’, ‘.bz2’ or ‘.xz’ be removed first?
A character string containing the error message if file x does not have the specified extensions
Only relevant when pooling assertions into multi-assertion helper functions. See cli_abort for details.
Advanced use only. Name of the argument passed (default: NULL, will automatically extract arg_name).
try({ assert_all_files_have_extension(c("foo.txt", "bar.txt"), extensions = "txt") # Passes assert_all_files_have_extension(c("foo.txt", "bar.csv"), extensions = "csv") # Throws Error })
Run the code above in your browser using DataLab