Skip to content
Prev 6184 / 63424 Next

Trailing "/" makes file.exists() return FALSE (PR#1098)

I agree to some extend, but I believe a consistent behavior across platforms
is something that should be a goal. Originally I found this problem from a
package (by a group only running WinNT and Solaris) trying to do

   system.file("",package="base")

which should work and give a path according to the help;

Usage:

     system.file(..., package = "base", lib.loc = .lib.loc, pkg, lib)

Arguments:

     ...: character strings, specifying subdirectory and file(s) within
          some package.  The default, none or `""', returns the root of
          the package.  Wildcards are not supported.
...

Doing this on WinMe it gives "". I can't try this on WinNT, but I assume it
works since the group that made the package it using it. I tracked down the
problem to originate in either the .find.package() call or the file.exists()
call done within system.file(). Which one is a matter of taste. Also, I
noticed that system.file(package="base") without the "", gives the wanted
result.

However, I still argue that file.exists() should be robust enough to give
the same answer if the argument is "foo/" or "foo". I don't know about any
filesystem that can have a file and a directory with the same name in the
same directory, so that shouldn't be an issue. Looking at Java, its solution
(java.io) is very robust across platforms. I am always thinking about the
end-user and making their life easier.

Thanks for a great work

Henrik Bengtsson

Dept. of Mathematical Statistics @ Centre for Mathematical Sciences
Lund Institute of Technology/Lund University, Sweden (+2h UTC)
Office: P316, +46 46 222 9611 (phone), +46 46 222 4623 (fax)
hb@maths.lth.se, http://www.maths.lth.se/matstat/staff/hb/
http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._.
_._
--
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._