[Rd] Proposed change in file.exists() to tolerate Windows
Richard Cotton
richierocks at gmail.com
Thu Sep 10 13:15:32 CEST 2015
Two solutions:
1. Use the wrapper function is_existing_file in assertive.
2. Use standardize_path in pathological before you call file.exists.
On 27 August 2015 at 17:02, 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
--
Regards,
Richie
Learning R
4dpiecharts.com
More information about the R-devel
mailing list