From hb at biostat.ucsf.edu  Tue Jan  7 01:24:30 2014
From: hb at biostat.ucsf.edu (Henrik Bengtsson)
Date: Mon, 6 Jan 2014 16:24:30 -0800
Subject: [Rd] file.info() on a file.symlink():ed file on Windows - is help
	correct?
Message-ID: <CAFDcVCQip9hs15kz4Tk7C+G+-D32MoCLCDKZn2oj8nm0qdrpdA@mail.gmail.com>

Is the following passage from help("file.info"):

"Junction points and symbolic links are followed, so information is
given about the file/directory to which the link points rather than
about the link."

correct?  Could it be that Windows was not considered?
help("file.symlink") mentions several Windows-related issues, but none
of those are related to the following.  On Windows 7 with a NTFS file
system I get that file.info() returns information about the symbolic
link rather than the file it points to.


REPRODUCIBLE EXAMPLE:

# Create a file
> cat("Hello", file="foo.txt")
> file.info("foo.txt")
        size isdir mode               mtime
foo.txt    5 FALSE  666 2014-01-06 15:53:27
                      ctime               atime exe
foo.txt 2014-01-06 15:43:07 2014-01-06 15:43:07  no
> bfr <- readChar("foo.txt", n=9)


# Create a symbolic link
> file.symlink("foo.txt", "link.exe")
TRUE
> file.info("link.exe")
         size isdir mode               mtime
link.exe    0 FALSE  777 2014-01-06 15:59:55
                       ctime               atime   exe
link.exe 2014-01-06 15:59:55 2014-01-06 15:59:55 msdos

> bfrL <- readChar("link.exe", n=9)
> stopifnot(identical(bfrL, bfr))


Note how file.info("link.exe")$size is 0 (zero) and none (except from
'dir') mirrors the file that the link points to.  I've verified that
'link.exe' is a symbolic link (and not a hard link); Windows reports
('dir' gives "01/06/2014  03:59 PM    <SYMLINK>      link.exe
[foo.txt]").

As a follow up, if the above is the proper/intended behavior of
file.info(), is it possible from within R to follow the link
"link.exe" to the target file "foo.txt" - such that one can get the
file.info() of that file instead?  (As help("Sys.readlink") says, it
won't work on Windows).

Thank you,

Henrik

> sessionInfo()
R Under development (unstable) (2014-01-05 r64665)
Platform: x86_64-w64-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
[6] methods   base

loaded via a namespace (and not attached):
[1] tools_3.1.0



[Rd] file.info() on a file.symlink():ed file on Windows - is help correct?
Henrik Bengtsson