From wdunlap at tibco.com  Fri Sep 23 17:49:43 2011
From: wdunlap at tibco.com (William Dunlap)
Date: Fri, 23 Sep 2011 15:49:43 +0000
Subject: [Rd] should dir(all=TRUE) return "." and ".."?
Message-ID: <E66794E69CFDE04D9A70842786030B93074E30@PA-MBX04.na.tibco.com>

dir(all=TRUE) returns the file names "." and ".."
while dir(recursive=TRUE, all=TRUE, include.dirs=TRUE)
does not.  I always filter out the "." and ".." entries
and was wondering if anyone would mind if dir(all=TRUE)
just omitted them?  It might make recursive file operations
like cleaning out a directory safer, as
  unlink(recursive=TRUE, dir(all=TRUE, "dirToClean"))
might start attacking dirToClean/.., then dirToClean/../..,
etc., until your disk is empty.

  > dir.create(tdir <- tempfile("tdir"))
  > file.create(file.path(tdir, c(".dotFile", "noDotFile")))
  [1] TRUE TRUE
  > dir.create(file.path(tdir, ".dotDir"))
  > file.create(file.path(tdir, ".dotDir", c("noDotFileInDotDir", ".dotFileInDotDir")))
  [1] TRUE TRUE
  > dir(tdir, all=TRUE) # omit "." and ".." here?
  [1] "."         ".."        ".dotDir"   ".dotFile" 
  [5] "noDotFile"
  > dir(tdir, all=TRUE, recursive=TRUE, include.dirs=TRUE)
  [1] ".dotDir"                   ".dotDir/.dotFileInDotDir" 
  [3] ".dotDir/noDotFileInDotDir" ".dotFile"                 
  [5] "noDotFile"                

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com 



[Rd] should dir(all=TRUE) return "." and ".."?
William Dunlap