[Rd] file.info(path) "inconsistent" with file.exists(path) when path == "C:/"

From: Henrik Bengtsson <hb_at_biostat.ucsf.edu>
Date: Sun, 18 Sep 2011 22:32:15 -0700


Hi,

on Windows 7 (tested on NTFS file system) and R-devel:

  1. file.info("C:/") gives NAs whilst file.exists("C:/") gives TRUE. Instead you have to do file.info("C:/.").
  2. Any number of dots will do, e.g. identical(file.info("C:/........."), file.info("C:/.")) == TRUE

DETAILS: # C:/ => DISCREPANCY file.exists() and file.info()
> file.exists("C:/")

[1] TRUE
> file.info("C:/")

    size isdir mode mtime ctime atime exe C:/ NA NA <NA> <NA> <NA> <NA> <NA>
> x <- list.files("C:/")
> str(x)

 chr [1:62] "$Recycle.Bin" "Boot" "bootmgr" "BOOTSECT.BAK" ...
> x <- shell('dir "C:/"', intern=TRUE)
> str(x)

 chr [1:57] " Volume in drive C is Windows7_OS" ...

# C:/. => OK
> file.exists("C:/.")

[1] TRUE
> file.info("C:/.")

     size isdir mode mtime ctime atime exe C:/. 0 TRUE 777 1980-01-01 1980-01-01 1980-01-01 no
> x <- list.files("C:/.")
> str(x)

 chr [1:62] "$Recycle.Bin" "Boot" "bootmgr" "BOOTSECT.BAK" ...
> x <- shell('dir "C:/."', intern=TRUE)
> str(x)

 chr [1:57] " Volume in drive C is Windows7_OS" ...

# C:/.. => OK
> file.exists("C:/..")

[1] TRUE
> file.info("C:/..")

      size isdir mode mtime ctime atime exe C:/.. 0 TRUE 777 1980-01-01 1980-01-01 1980-01-01 no
> x <- list.files("C:/..")
> str(x)

 chr [1:62] "$Recycle.Bin" "Boot" "bootmgr" "BOOTSECT.BAK" ...
> x <- shell('dir "C:/.."', intern=TRUE)
> str(x)

 chr [1:57] " Volume in drive C is Windows7_OS" ...

# C:/... => SURPRISE IN R
> file.exists("C:/...")

[1] TRUE
> file.info("C:/...")

       size isdir mode mtime ctime atime exe C:/... 0 TRUE 777 1980-01-01 1980-01-01 1980-01-01 no
> x <- list.files("C:/...")
> str(x)

 chr [1:62] "$Recycle.Bin" "Boot" "bootmgr" "BOOTSECT.BAK" ...
> x <- shell('dir "C:/..."', intern=TRUE)
File Not Found
Warning message:
running command 'C:\Windows\system32\cmd.exe /c dir "C:/..."' had status 1

> sessionInfo()

R Under development (unstable) (2011-09-13 r57004) Platform: x86_64-pc-mingw32/x64 (64-bit)

locale:

[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base


/Henrik



R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Mon 19 Sep 2011 - 05:35:25 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 Mon 19 Sep 2011 - 17:40:33 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