system-independent path for source()
That looks good, except the hard disk name should be kept separate from
the user-specified path. Otherwise, a call from MacOS that uses an
absolute path will not work on UNIX.
I suggest modifying your file.path interface:
file.path<-function (..., fsep = .Platform$file.sep,absolute=FALSE,
hard.disk.name = "C") {}
If .Platform$OS.type=="mac" and absolute, then hard.disk.name would be
added to the beginning of the path.
This way, file.path("Users","thomas",absolute=TRUE, hard.disk.name =
"Macintosh HD") would work for both MacOS and UNIX. I think this
interface could also be made to work with Windows.
On Wednesday, February 20, 2002, at 04:32 ?, Thomas Lumley wrote:
On Wed, 20 Feb 2002, Prof Brian Ripley wrote:
All contributions welcome, Thomas!
This seems to be a bit better than the current version, and I'll add it
file.path<-function (..., fsep = .Platform$file.sep,absolute=FALSE) {
rval<-paste(..., sep = fsep)
if (xor(absolute,.Platform$OS.type=="mac"))
rval<-paste("",rval,sep=fsep)
rval
}
so now I can do
file.path("Macintosh HD","Users","thomas",absolute=TRUE)
or
file.path("Users","thomas")
for a relative path.
The real question is what to do about disks. In Windows you need the
disk
name to find files on other disks but on the Mac you seem to need the
disk name even to find the root of the current disk.
It could be taken from getwd() but that seems to make file.path() a lot
more complicated and less portable.
-thomas
http://www.mcg.edu/research/biostat/bickel.html David R. Bickel, PhD Assistant Professor Medical College of Georgia Office of Biostatistics and Bioinformatics 1120 Fifteenth St., AE-3037 Augusta, GA 30912-4900 Tel.: 706-721-4697; Fax: 706-721-6294 E-mail: dbickel at mail.mcg.edu or bickel at prueba.info -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._