Re: [Rd] Non-recursive way to remove empty directory on Windows?

From: William Dunlap <wdunlap_at_tibco.com>
Date: Thu, 29 Nov 2012 02:36:54 +0000

> (even worse, path may contain '..' or
> likewise from a list.files(all.names=TRUE) call)

Would anyone's code break if "." and ".." were never in the output of list.files() (or dir())? I find it tedious to skip them whenever doing anything recursive in the file system. They are not in the output of the unix find command and no one misses them there.

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com

> -----Original Message-----
> From: r-devel-bounces_at_r-project.org [mailto:r-devel-bounces_at_r-project.org] On Behalf
> Of Henrik Bengtsson
> Sent: Wednesday, November 28, 2012 6:25 PM
> To: R-devel
> Subject: [Rd] Non-recursive way to remove empty directory on Windows?
>
> Hi,
>
> file.remove(path) will remove an empty directory "on most Unix
> platforms", but not on Windows, cf. help("file.remove"). A workaround
> for Windows is then unlink(path, recursive=TRUE). However, unless
> you're really careful and make sure 'path' is not empty, you may
> delete more than you wish (even worse, path may contain '..' or
> likewise from a list.files(all.names=TRUE) call). Is there another

> *non-recursive* way to delete a single empty directory on Windows
> (without turning to system() calls)?
>
> Thanks,
>
> Henrik
>
> ______________________________________________
> R-devel_at_r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel



R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Thu 29 Nov 2012 - 03:24:50 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

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 Fri 30 Nov 2012 - 12:02:20 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