From wdunlap at tibco.com  Thu Nov 29 03:36:54 2012
From: wdunlap at tibco.com (William Dunlap)
Date: Thu, 29 Nov 2012 02:36:54 +0000
Subject: [Rd] Non-recursive way to remove empty directory on Windows?
In-Reply-To: <CAFDcVCRTbVYWK_nGNSwObCmUzQySoqtPgOwLE5RO1wdzEGdcDQ@mail.gmail.com>
References: <CAFDcVCRTbVYWK_nGNSwObCmUzQySoqtPgOwLE5RO1wdzEGdcDQ@mail.gmail.com>
Message-ID: <E66794E69CFDE04D9A70842786030B931B8BD0CC@PA-MBX01.na.tibco.com>

> (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



[Rd] Non-recursive way to remove empty directory on Windows?
William Dunlap