hb@maths.lth.se
2001-Sep-24 08:46 UTC
[Rd] Trailing "/" makes file.exists() return FALSE (PR#1098)
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)); } 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
ripley@stats.ox.ac.uk
2001-Sep-24 10:09 UTC
[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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
hb@maths.lth.se
2001-Sep-24 11:30 UTC
[Rd] 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/> -----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 -- Readhttp://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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
ripley@stats.ox.ac.uk
2001-Sep-24 11:50 UTC
[Rd] Trailing "/" makes file.exists() return FALSE (PR#1098)
On Mon, 24 Sep 2001, Henrik Bengtsson wrote:> 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 aBut the underlying OSes are not consistent, and the nature of your `bug' report is that R is being truthful on each. Which is the sort of consistency we want.> 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. > ...That's not correct, and not in the current R sources. It is a documentation bug that has already been fixed: search the bug report database for system.file (it's not talking to me right now).> 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.In which case think what happens when file.exists() incorrectly reports a file as existing when it does not, and the user then tries to make use of the file? Let me stress (since you do seem to have missed the point) that "foo/" is not a file on Windows, nor a directory on Windows. It does not exist. Whatever would be the point of a test that lied to you?> 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 > > >-- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Seemingly Similar Threads
- setClass() and packages
- savehistory: Suggestions to a \seealso{} (PR#1104)
- Is it possible to open a specific file in the HTML browser like help(htmlhelp=TRUE) does?
- Incorrect display of b[hat((a))] expression in plots
- Loading tcltk package fails on WinMe/Cygwin but works with Rgui