richard_raubertas@merck.com
2003-Jul-21 19:27 UTC
[Rd] Bug in file.copy: overwrite=FALSE ignored (PR#3529)
I am using R 1.7.1 on Windows XP Pro. The 'overwrite=FALSE' argument appears to be ignored in file.copy():> file.exists(c("file1.txt", "file2.txt"))[1] TRUE TRUE> file.copy(from="file2.txt", to="file1.txt", overwrite=FALSE)[1] TRUE>and sure enough, file1.txt has been overwritten. Rich Raubertas Biometrics Research, RY33-300 Merck & Co. ------------------------------------------------------------------------------ Notice: This e-mail message, together with any attachments, ...{{dropped}}
richard_raubertas@merck.com wrote:> I am using R 1.7.1 on Windows XP Pro. > > The 'overwrite=FALSE' argument appears to be ignored in > file.copy(): > > >>file.exists(c("file1.txt", "file2.txt")) > > [1] TRUE TRUE > >>file.copy(from="file2.txt", to="file1.txt", overwrite=FALSE) > > [1] TRUE > > > and sure enough, file1.txt has been overwritten. > > Rich Raubertas > Biometrics Research, RY33-300 > Merck & Co. > > ------------------------------------------------------------------------------ > Notice: This e-mail message, together with any attachments, ...{{dropped}} > > ______________________________________________ > R-devel@stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-develFix: if (!overwrite) { if (nt > nf) from <- rep(from, length = nt) exists <- file.exists(from) from <- from[exists] to <- to[exists] } file.create(to) file.append(to, from) should be something like if (!overwrite) { if (nt > nf) from <- rep(from, length = nt) exists <- file.exists(to) if(sum(exists)) warning("File(s) \"", paste(to[exists], collapse = ", "), "\" already exist(s)") from <- from[!exists] to <- to[!exists] } if (length(to)) { file.create(to) file.append(to, from) } Uwe Ligges
Duncan Murdoch
2003-Jul-21 20:16 UTC
[Rd] Bug in file.copy: overwrite=FALSE ignored (PR#3529)
On Mon, 21 Jul 2003 19:27:34 +0200 (MET DST), richard_raubertas@merck.com wrote :>I am using R 1.7.1 on Windows XP Pro. > >The 'overwrite=FALSE' argument appears to be ignored in >file.copy(): > >> file.exists(c("file1.txt", "file2.txt")) >[1] TRUE TRUE >> file.copy(from="file2.txt", to="file1.txt", overwrite=FALSE) >[1] TRUE >> > >and sure enough, file1.txt has been overwritten.There was a bug in the file.copy code; I'll submit a patch. Duncan Murdoch