[Rd] file separator inconsistencies on windows?

Prof Brian Ripley ripley at stats.ox.ac.uk
Mon May 14 18:20:33 CEST 2007

On Mon, 14 May 2007, Ernest Turro wrote:

> tempdir() on windows returns the path using "\\" as file separator.

Yes, it is explicitly documented to.

> But .Platform$file.sep returns "/". As a result, you get
> inconsistencies like:
> > file.path(tempdir(), "foo")
> [1] "C:\\WINDOWS\\Temp\\RtmpYEIXrb/foo" # Mix of \\ and /
> I'm not sure if this can cause problems but I thought I'd let you
> know just in case.

It doesn't cause problems AFAIK.  The main place you need \ is when 
passing filepaths to a Windows shell, a few Windows executables and a very 
few API functions (where we convert in the wrappers).  OTOH, / is needed 
when passing to a Unix-like shell, make ....

Note that e.g. shell() on Windows has an argument to translate / to \ if 

There is a problem with network shares like \\machine\path\to\file.  Those 
are essentially incompatible with POSIX and a lot of the tools we use for 
R, but I've started to make them work as far as is practicable.

Brian D. Ripley,                  ripley at 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 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

More information about the R-devel mailing list