powered by
I often want a timestamped copy as backup of a file or directory.
file_save( x, file_extension_pattern = "\\.[A-z]{1,5}$", force = TRUE, recursive = dir.exists(x), stop_on_error = TRUE )
A path to a file.
A Pattern to mark a file extension. If matched, the time stamp will get inserted before that pattern.
Force even if file_extension_pattern is not matched. Set to FALSE to skip stamping such files.
file_extension_pattern
FALSE
Passed to file.copy.
file.copy
Throw an exception on error?
TRUE on success, FALSE otherwise.
TRUE
Other operating system functions: file_copy(), get_boolean_envvar(), get_run_r_tests(), is_installed(), is_r_package_installed(), is_success(), is_windows(), view(), vim(), with_dir()
file_copy()
get_boolean_envvar()
get_run_r_tests()
is_installed()
is_r_package_installed()
is_success()
is_windows()
view()
vim()
with_dir()
Other file utilities: file_copy(), file_modified_last(), find_files(), get_mtime(), get_unique_string(), is_files_current(), is_path(), paths, search_files(), split_code_file(), touch()
file_modified_last()
find_files()
get_mtime()
get_unique_string()
is_files_current()
is_path()
paths
search_files()
split_code_file()
touch()
# NOT RUN { f <- tempfile() try(file_save(f)) touch(f) file_save(f, recursive = FALSE) f <- paste0(file.path(tempfile()), ".txt") touch(f) file_save(f) # file.copy gives a warning dir(tempdir()) # }
Run the code above in your browser using DataLab