From ripley at stats.ox.ac.uk  Mon May 14 18:20:33 2007
From: ripley at stats.ox.ac.uk (Prof Brian Ripley)
Date: Mon, 14 May 2007 17:20:33 +0100 (BST)
Subject: [Rd] file separator inconsistencies on windows?
In-Reply-To: <4D68C58E-A646-4954-9829-EC8A51959D2A@ic.ac.uk>
References: <4D68C58E-A646-4954-9829-EC8A51959D2A@ic.ac.uk>
Message-ID: <Pine.LNX.4.64.0705141355270.30205@gannet.stats.ox.ac.uk>

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

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



[Rd] file separator inconsistencies on windows?
Prof Brian Ripley