From tomas.kalibera at gmail.com  Tue Apr 10 01:03:29 2018
From: tomas.kalibera at gmail.com (Tomas Kalibera)
Date: Tue, 10 Apr 2018 01:03:29 +0200
Subject: [Rd] file.copy(from=Directory, to=File) oddity
In-Reply-To: <CAF8bMcaP2dHS3KAZVyXifuigZ3B2LmoR6N+=vdzBaCF5svGrhg@mail.gmail.com>
References: <CAF8bMcaP2dHS3KAZVyXifuigZ3B2LmoR6N+=vdzBaCF5svGrhg@mail.gmail.com>
Message-ID: <86301d5b-0bab-d147-6f71-38dd62252787@gmail.com>

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



[Rd] file.copy(from=Directory, to=File) oddity
Tomas Kalibera