Thanks for the report, fixed in R-devel. Now we get a warning when
copying a directory over a non-directory file is attempted. The target
(non-directory) file is left alone.
Tomas
On 09/08/2017 06:54 PM, William Dunlap via R-devel wrote:
When I mistakenly use file.copy() with a directory for
Bug 17337. Note that I get R making the zero-length file on both Windows
and Linux, but the return values are different.
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Mon, Sep 11, 2017 at 7:01 AM, Martin Maechler wrote:
> > William Dunlap via R-devel
> > on Fri, 8 Sep 2017 09:54
> William Dunlap via R-devel
> on Fri, 8 Sep 2017 09:54:58 -0700 writes:
> 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. How
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(fi
It appears that file.copy() does not protect against the case when one
copies one directory to a subdirectory of itself resulting in it
trying to create and endless recursive copy of itself.
REPRODUCIBLE EXAMPLE:
src <- "foo"
dir.create(src);
file.copy(src, src, recursive=FALSE) # ok
file.copy(src
FYI: I reported this to r-devel on July 23, 2006:
http://tolstoy.newcastle.edu.au/R/devel/06/07/6220.html
There was no follow up.
/Henrik
On 1/17/07, Herve Pages <[EMAIL PROTECTED]> wrote:
> Hi,
>
> Copying a non-existing file with file.copy creates an empty file
>
> > r <- file.copy("non-ex
Hi,
Copying a non-existing file with file.copy creates an empty file
> r <- file.copy("non-existing-file", ".")
> r
[1] TRUE
... and returns TRUE!
Now, when used in "vectorized" mode
> r <- file.copy(c("toto1", "toto2"), c("dest1", "dest2"))
[1] FALSE FALSE
file.copy looks much more
Copying a non-existing file using file.copy() creates empty file. Example:
> file.exists("non-existing-file")
[1] FALSE
> file.copy("non-existing-file", "new-file")
> file.exits("new-file")
[1] TRUE
> file.info("new-file")$size
[1] 0
The reason for this is that file.copy() calls file.create() wi