From wdunlap at tibco.com  Thu Aug 27 16:16:46 2015
From: wdunlap at tibco.com (William Dunlap)
Date: Thu, 27 Aug 2015 07:16:46 -0700
Subject: [Rd] Proposed change in file.exists() to tolerate Windows
In-Reply-To: <CAErODj9qf7BiGV1n9Vu9d0nyiCeOFQm7DJzTrH0vZgTQsm5nTQ@mail.gmail.com>
References: <CAErODj9qf7BiGV1n9Vu9d0nyiCeOFQm7DJzTrH0vZgTQsm5nTQ@mail.gmail.com>
Message-ID: <CAF8bMcY9dn8Uu9ua3wykkrCjeuKR1=jMS6o=pYHi=GonWwOVyQ@mail.gmail.com>

   ## delete trailing slashes
   dts <- function(name) gsub("/$", "", name)
   if(!file.exists(dts(any_name))) { ...

I don't think you want to delete the slash in "C:/" on Windows,
as "C:" is not a file and "C:/" is.  normalizePath() does odd things
with "C:" as well.



Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Thu, Aug 27, 2015 at 7:02 AM, Paul Johnson <pauljohn32 at gmail.com> wrote:

> I'm writing to ask if R Core would make file.exists more Windows
> tolerant when the argument has a trailing slash. This has been
> discussed by users a few times here, I know it is not a new topic. But
> it is not a solved problem, yet. I acknowledge that CRAN packages
> exist which fix this by replacing file.exists(), but it seems more
> elegant to me to fix the problem in R itself.
>
> R Core goes to great extremes to accommodate Windows users and the
> refusal to make file.exists() work in a cross-platform way is
> incongruous.
>
> I often do have slashes on the end of directory names being tested.
> Now that I understand the meaning of ?file.exists,  I need to wrap the
> name being checked in a slash-deleter
>
> ## delete trailing slashes
> dts <- function(name) gsub("/$", "", name)
> if(!file.exists(dts(any_name))) { ...
>
> Can't you make file.exists do this invisibly? Maybe the argument could
> be filtered through normalizePath() instead.
>
> If not, would you please consider putting a workaround like mine into
> the file.exists documentation so Windows users can see how easy this
> is to avoid?
>
> Respectfully yours,
>
> pj
>
> --
> Paul E. Johnson
> Professor, Political Science        Director
> 1541 Lilac Lane, Room 504      Center for Research Methods
> University of Kansas                 University of Kansas
> http://pj.freefaculty.org              http://crmda.ku.edu
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

	[[alternative HTML version deleted]]



[Rd] Proposed change in file.exists() to tolerate Windows
William Dunlap