copyFile
Copies a file atomically
Copies a file atomically, by first copying to a temporary file and then renaming that file.
- Keywords
- internal
Usage
# S3 method for default
copyFile(srcPathname, destPathname, skip=FALSE, overwrite=FALSE, ..., validate=TRUE,
verbose=FALSE)
Arguments
- srcPathname
The source file to be copied.
- destPathname
The destination file to be created. If an existing directory, then the destination file becomes
file.path(destPathname, basename(srcPathname))
.- skip, overwrite
If a destination file does not exist, these arguments have no effect. If such a file exists and
skip
isTRUE
, then no copying is attempted andFALSE
is returned (indicating that no copying was made). If such a file exists, bothskip
andoverwrite
areFALSE
then an exception is thrown. If a destination file exists,skip
isFALSE
andoverwrite
isTRUE
, then it is overwritten andTRUE
is returned. If the copying/overwriting failed, for instance due to non sufficient file permissions, an informative exception is thrown.- ...
Additional named arguments passed to
file.copy
(). Non-named or unknown arguments are ignored.- validate
If
TRUE
, validation of the copied file is applied, otherwise not.- verbose
See
Verbose
.
Details
If the source file does not exists (or is not a file), then an informative exception is thrown.
If the source and destination pathnames are the same, it is not safe to copy (which can lead to either corrupt or lost files) and an informative exception is thrown.
If (and only if) the file is successfully copied and argument
validate
is TRUE
, then this method also asserts that the
file size of the destination matches that of the source, otherwise
an informative exception is thrown.
Value
Returns a logical
indicating whether a successful file copy was
completed or not, or equivalently. In other words, TRUE
is returned
if the file was successfully copied, and FALSE
if not.
If an error occurs, an informative exception is thrown.
If the error occurs while renaming the temporary file to the final name,
the temporary file will remain in the destination directory.
See Also
file.copy()
.