potential file.copy() or documentation bug when copy.date = TRUE

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

potential file.copy() or documentation bug when copy.date = TRUE

Gábor Csárdi
This is a recent R-devel. file.copy() is not vectorized if multiple
destinations succeed:

cat("foo1\n", file = "foo1")
cat("foo2\n", file = "foo2")
unlink(c("copy1", "copy2"), recursive = TRUE)

file.copy(c("foo1", "foo2"), c("copy1", "copy2"), copy.date = TRUE)

#> Error in Sys.setFileTime(to[okay], fi$mtime) : invalid 'path' argument

# But the files were still copied:
file.exists(c("copy1", "copy2"))
#> [1] TRUE TRUE

file.copy(c("foo1", "foo2"), c("copy1", "copy2"))
#> [1] FALSE FALSE

file.copy(c("foo1", "foo2"), c("copy1", "copy2"), copy.date = TRUE)
#> [1] FALSE FALSE

file.copy(c("foo1", "foo2"), c("copy1", "copy2"), copy.date = TRUE,
overwrite = TRUE)
#> Error in Sys.setFileTime(to[okay], fi$mtime) : invalid 'path' argument

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: potential file.copy() or documentation bug when copy.date = TRUE

Tomas Kalibera
Thanks for the report, fixed in R-devel.

Best,
Tomas

On 04/05/2018 05:01 PM, Gábor Csárdi wrote:

> This is a recent R-devel. file.copy() is not vectorized if multiple
> destinations succeed:
>
> cat("foo1\n", file = "foo1")
> cat("foo2\n", file = "foo2")
> unlink(c("copy1", "copy2"), recursive = TRUE)
>
> file.copy(c("foo1", "foo2"), c("copy1", "copy2"), copy.date = TRUE)
>
> #> Error in Sys.setFileTime(to[okay], fi$mtime) : invalid 'path' argument
>
> # But the files were still copied:
> file.exists(c("copy1", "copy2"))
> #> [1] TRUE TRUE
>
> file.copy(c("foo1", "foo2"), c("copy1", "copy2"))
> #> [1] FALSE FALSE
>
> file.copy(c("foo1", "foo2"), c("copy1", "copy2"), copy.date = TRUE)
> #> [1] FALSE FALSE
>
> file.copy(c("foo1", "foo2"), c("copy1", "copy2"), copy.date = TRUE,
> overwrite = TRUE)
> #> Error in Sys.setFileTime(to[okay], fi$mtime) : invalid 'path' argument
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel