Tests whether all the files in a given directory have a modification date
equal to the system date. Useful when repeatedly running code with a lengthy
download stage. Many state databases are updated daily, so new data can be
helpful but not always necessary. Set this function in an if
statement.
all_files_new(path, glob = NULL, ...)
The path to a directory to check.
A pattern to search for files (e.g., "*.csv").
Additional arguments passed to fs::dir_ls()
.
logical; Whether all()
files in the directory have a modification
date equal to today.
tmp <- tempdir()
file.create(tempfile(pattern = as.character(1:5)))
#> [1] TRUE TRUE TRUE TRUE TRUE
all_files_new(tmp)
#> [1] TRUE