Henrik Bengtsson
2011-Sep-19 05:32 UTC
[Rd] file.info(path) "inconsistent" with file.exists(path) when path == "C:/"
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