[Rd] should Sys.glob() cope with a UNC windows path beginning with backslashes?

Prof Brian Ripley ripley at stats.ox.ac.uk
Sat Jun 27 07:16:57 CEST 2009


On Fri, 26 Jun 2009, Tony Plate wrote:

> I find that Sys.glob() doesn't like UNC paths where the initial slashes are 
> backslashes.  The help page for Sys.glob() doesn't specificly mention UNC 
> paths, but does say: "File paths in Windows are interpreted with separator \ 
> or /."  Is the failure to treat a path beginning with a double-backslash as a 
> UNC network drive path the intended behavior?

Yes.  There are general warnings about non-POSIX Windows paths in 
several of the help files.

The following comments should alert you to possible restrictions:

   The \code{glob} system call is not part of Windows, and we supply an
   emulation.

   File paths in Windows are interpreted with separator \code{\\} or
   \code{/}.  Paths with a drive but relative (such as \code{c:foo\\bar})
   are tricky, but an attempt is made to handle them correctly.

If you want to submit a well-tested patch, it will be considered.

>
> E.g., on a Windows system where \\foo is a network drive and \\foo\bar 
> exists, I see:
>
>> Sys.glob("//foo/bar")
> [1] "//foo/bar"
>> Sys.glob("//foo\\bar")
> [1] "//foo\\bar"
>> Sys.glob("\\\\foo/bar")
> character(0)
>> Sys.glob("\\\\foo\\bar")
>> 
> (the pattern of behavior seems to be that initial backslashes are not 
> equivalent to forward slashes, but later backslashes are.)
>
> This is not a big deal, but I noticed it because it results in Rcmd check 
> giving a spurious warning when started from a cygwin shell with a working 
> directory that is a network drive specified as a UNC path.  This happens 
> because mandir in tools:::.writePkgIndices has the form 
> \\foo/bar/R/packages/mypkg/man, which results in the false warning "there is 
> a 'man' dir but no help pages in this package."  A simple workaround was to 
> use a drive-letter mount for the network drive.
>
>> sessionInfo()
> R version 2.9.1 (2009-06-26) i386-pc-mingw32 
> locale:
> LC_COLLATE=English_United States.1252;LC_CTYPE=English_United 
> States.1252;LC_MONETARY=English_United 
> States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252
>
> attached base packages:
> [1] stats     graphics  grDevices utils     datasets  methods   base 
>> 
>
> -- Tony Plate
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

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