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

ripley@stats.ox.ac.uk ripley@stats.ox.ac.uk
Mon, 24 Sep 2001 12:09:43 +0200 (MET DST)


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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._