[Rd] file.copy(from=Directory, to=File) oddity
William Dunlap
wdunlap at tibco.com
Fri Sep 8 18:54:58 CEST 2017
When I mistakenly use file.copy() with a directory for the 'from' argument
and a non-directory for the 'to' and overwrite=TRUE, file.copy returns
FALSE, meaning it could not do the copying. However, it also replaces the
'to' file with a zero-length file.
dir.create( fromDir <- tempfile() )
cat(file = toFile <- tempfile(), "existing file\n")
readLines(toFile)
#[1] "existing file"
file.copy(fromDir, toFile, recursive=FALSE, overwrite=TRUE)
#[1] FALSE
readLines(toFile)
#character(0)
or, with recursive=TRUE,
dir.create( fromDir <- tempfile() )
cat(file = toFile <- tempfile(), "existing file\n")
readLines(toFile)
#[1] "existing file"
file.copy(fromDir, toFile, recursive=TRUE, overwrite=TRUE)
#[1] FALSE
#Warning message:
#In file.copy(fromDir, toFile, recursive = TRUE, overwrite = TRUE) :
# 'recursive' will be ignored as 'to' is not a single existing directory
readLines(toFile)
#character(0)
Is this behavior intended?
Bill Dunlap
TIBCO Software
wdunlap tibco.com
[[alternative HTML version deleted]]
More information about the R-devel
mailing list