Re: [Rd] A strange behaviour of file.path in Windows? (PR#13119)

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Fri, 03 Oct 2008 12:02:39 +0100 (BST)

On Fri, 3 Oct 2008, pego.enrico_at_tiscali.it wrote:

> Full_Name: Enrico Pegoraro
> Version: 2.7.2
> OS: Windows (Vista or Xp PRO) Italian
> Submission from: (NULL) (87.4.189.202)
>
>
> If you send these lines of code:
>
> outdir="c:/pippo"
> file.path(outdir,"pluto.html")
>
> R replies correctly:
>
> [1] "c:/pippo/pluto.html"
>
> But if you change the first steps to:
>
> outdir=""
> file.path(outdir,"pluto.html")
>
> R replies (uncorrectly, I think)

> [1] "/c:/pippo/pluto.html"

Not for me! I get

> outdir=""
> file.path(outdir,"pluto.html")

[1] "/pluto.html"

which is as documented, hence correct. Furthermore, the code cannot possibly give your answer unless 'c:/pippo' has some special status on your system, and you haven't told us anything about that.

If you do

file.path("", "c:/pippo", "pluto.html")

you get what you indicate, but that is user error (an empty server/share specification).

>
> This problem influence the R2HTML package too, which, if you send a line as:
>
> targetHtml=HTMLInitFile(outdir="",filename="htmlFile",Title ="Title")
>
> in windows it submit an error because of file.path() error.

It will affect any such misuse of file.path, of course. It really is not a good idea to use empty file path elements, especially on Windows[*]. If you mean the current directory, use ".".

[*] On Unix // is equivalent to /. On Windows \\ or // may have a special meaning (a share) or be regarded as invalid. A trailing / or \ can be disastrous.

> Thank you
> Enrico

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

______________________________________________
R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Received on Fri 03 Oct 2008 - 11:10:29 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 03 Oct 2008 - 14:30:16 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive