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]] ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel