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, ...)

Arguments

path

The path to a directory to check.

glob

A pattern to search for files (e.g., "*.csv").

...

Additional arguments passed to fs::dir_ls().

Value

logical; Whether all() files in the directory have a modification date equal to today.

Examples

tmp <- tempdir()
file.create(tempfile(pattern = as.character(1:5)))
#> [1] TRUE TRUE TRUE TRUE TRUE
all_files_new(tmp)
#> [1] TRUE