| file_copy {fritools2} | R Documentation |
Force Copying a File While Backing it up
Description
file.copy has an argument overwrite that allows for
overwriting existing files. But I often want to overwrite an existing file
while creating a backup copy of that file.
Usage
file_copy(from, to, stop_on_error = FALSE, ...)
Arguments
from |
See |
to |
See |
stop_on_error |
Throw an exception on error? |
... |
Arguments passed to |
Value
A vector of boolean values indicating
success or failure.
See Also
Other file utilities:
clipboard_path(),
delete_trailing_blank_lines(),
delete_trailing_whitespace(),
develop_test(),
file_modified_last(),
file_save(),
find_files(),
get_lines_between_tags(),
get_mtime(),
get_unique_string(),
grep_file(),
is_files_current(),
is_path(),
paths,
search_files(),
split_code_file(),
touch()
Other operating system functions:
clipboard_path(),
file_save(),
get_boolean_envvar(),
get_run_r_tests(),
is_installed(),
is_r_package_installed(),
is_success(),
is_windows(),
view(),
vim(),
wipe_tempdir(),
with_dir()
Examples
touch(f1 <- file.path(tempdir(), "first.R"),
f2 <- file.path(tempdir(), "second.R"))
dir.create(t <- file.path(tempdir(), "foo"))
file_copy(from = c(f2, f1), to = t)
dir(t)
touch(f1)
touch(f2)
file_copy(from = c(f2, f1), to = t)
dir(t)
list.files(tempdir(), pattern = "first.*\\.R")
dir <- file.path(tempdir(), "subdir")
dir.create(dir)
file_copy(f1, dir)
touch(f1)
file_copy(f1, dir)
list.files(dir, pattern = "first.*\\.R")