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/
-----Original Message----- From: Prof Brian Ripley [mailto:ripley@stats.ox.ac.uk] Sent: Monday, September 24, 2001 12:10 PM To: hb@maths.lth.se Cc: R-bugs@biostat.ku.dk Subject: Re: [Rd] Trailing "/" makes file.exists() return FALSE (PR#1098) On Mon, 24 Sep 2001 hb@maths.lth.se wrote:
Full_Name: Henrik Bengtsson Version: 1.3.1 OS: WinMe Submission from: (NULL) (130.235.2.229) I found the following bug on WinMe (I call it a bug, since the
behavior is
different on WinMe than for instance Sun Solaris): When calling file.exists() with an existing directory name
ending with a "/"
(slash) [R] on WinMe will return FALSE, but when doing the same
without the
ending "/" it will give TRUE. I made a quick work around, but this should be taken care of in
the native
code:
file.exists <- function(...) {
# Remove trailing "/", but keep "C:/", "D:/"...
files <- gsub("\:/$", "\://", c(...));
files <- gsub("/$", "", files);
.Internal(file.exists(files));
}
This is not a bug. A file path ending with "/" is not a file on Windows, but it is on Solaris. Next you'll be reporting that file specifications with drives fail on Solaris: it other words, what is a valid file path is OS-specific. You'll find quite a lot of Windows tools reject paths ending in /: for example the ls in Rtools thinks the directory is non-existent. Similarly, Solaris accepts // in paths, but Windows does not.
platform i386-pc-mingw32 arch x86 os Win32 system x86, Win32 status major 1 minor 3.1 year 2001 month 08 day 31 language R
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. -.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._. _._
-- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._