[Rd] file.rename(): Guaranteed to be complete or not at all?

From: Henrik Bengtsson <hb_at_biostat.ucsf.edu>
Date: Tue, 01 Mar 2011 20:41:53 -0800


Hi,

assume I have an existing file 'pathname' and I want to rename it to 'pathnameN' (which does not exist). I use:

res <- file.rename(pathname, pathnameN);

Is it guaranteed that:

(1) if res == TRUE, the file now have name 'pathnameN' and there is no
file with name 'pathname'?
(2) if res == FALSE, nothing has changed?

or could it theoretically also be the case that

(3) there are say two identical files named 'pathname' and 'pathnameN',
(4) or worse, that neither exists?

I can see how (3) could happen if the file is renamed by first using file.copy() and then file.remove() while there is lack of write/delete permission for the latter.

Currently, my code asserts that (3) and (4) did not happen. Is that unnecessary - does file.rename() do that for me (regardless of OS)?

Thanks

Henrik



R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Wed 02 Mar 2011 - 04:47:39 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 02 Mar 2011 - 12:20:25 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive