Platform.Rd 3.87 KB
Newer Older
Radford Neal's avatar
Radford Neal committed
1 2
% File src/library/base/man/Platform.Rd
% Part of the R package, http://www.R-project.org
3
% Copyright 1995-2011 R Core Team
Radford Neal's avatar
Radford Neal committed
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
% Distributed under GPL 2 or later

\name{.Platform}
\title{Platform Specific Variables}
\usage{
.Platform
}
\alias{.Platform}
\description{
  \code{.Platform} is a list with some details of the platform under
  which \R was built.  This provides means to write OS-portable \R
  code.
}
\value{
  A list with at least the following components:
  
  \item{OS.type}{
    character string, giving the \bold{O}perating \bold{S}ystem
    (family) of the computer.  One of \code{"unix"} or \code{"windows"}.
  }
  \item{file.sep}{
    character string, giving the \bold{file} \bold{sep}arator used on your
    platform: \code{"/"} on both Unix-alikes \emph{and} on Windows (but
    not on the once port to Classic Mac OS).
  }
  \item{dynlib.ext}{
    character string, giving the file name \bold{ext}ension of
    \bold{dyn}amically loadable \bold{lib}raries, e.g., \code{".dll"} on
    Windows and \code{".so"} or \code{".sl"} on Unix-alikes.  (Note for
    Mac OS X users: these are shared objects as loaded by
    \code{\link{dyn.load}} and not dylibs: see \code{\link{dyn.load}}.)
  }
  \item{GUI}{
    character string, giving the type of GUI in use, or \code{"unknown"}
    if no GUI can be assumed.  Possible values are for Unix-alikes the
    values given via the \option{-g} command-line flag (\code{"X11"},
    \code{"Tk"}), \code{"AQUA"} (running under \code{R.app} on Mac OS X),
    \code{"Rgui"} and \code{"RTerm"} (Windows) and perhaps others under
    alternative front-ends or embedded \R.
  }
  \item{endian}{
    character string, \code{"big"} or \code{"little"}, giving the
    endianness of the processor in use.  This is relevant when it is
    necessary to know the order to read/write bytes of e.g. an integer or
Radford Neal's avatar
Radford Neal committed
48
    double from/to a \link{connection}: see \code{\link{readBin}}. 
Radford Neal's avatar
Radford Neal committed
49 50 51 52
  }
  \item{pkgType}{
    character string, the preferred setting for
    \code{\link{options}("pkgType")}.  Values \code{"source"},
Radford Neal's avatar
Radford Neal committed
53 54
    \code{"mac.binary.leopard"} and \code{"win.binary"} are currently in
    use.
Radford Neal's avatar
Radford Neal committed
55 56 57 58 59 60 61 62
  }
  \item{path.sep}{
    character string, giving the \bold{path} \bold{sep}arator,
    used on your platform, e.g., \code{":"} on Unix-alikes and
    \code{";"} on Windows.  Used to separate paths in environment
    variables such as \code{PATH} and \code{TEXINPUTS}.
  }
  \item{r_arch}{
Radford Neal's avatar
Radford Neal committed
63
    character string, possibly \code{""}.  The name of an
Radford Neal's avatar
Radford Neal committed
64 65 66 67 68 69 70 71
    architecture-specific directory used in this build of \R.
  }
}

\section{AQUA}{
  \code{.Platform$GUI} is set to \code{"AQUA"} under the Mac OS X GUI,
  \code{R.app}. This has a number of consequences:
  \itemize{
Radford Neal's avatar
Radford Neal committed
72
    \item the \env{DISPLAY} environment variable is set to \code{":0"} if unset.
Radford Neal's avatar
Radford Neal committed
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
    \item appends \file{/usr/local/bin} to the \env{PATH} environment variable.
    \item the default graphics device is set to \code{quartz}.
    \item selects native (rather than Tk) widgets for the \code{graphics
      = TRUE} options of \code{\link{menu}} and \code{\link{select.list}}.
    \item HTML help is displayed in the internal browser.
    \item The spreadsheet-like data editor/viewer uses a Quartz version
    rather than the X11 one.
  }
}
\seealso{
  \code{\link{R.version}} and \code{\link{Sys.info}} give more details
  about the OS.  In particular, \code{R.version$platform} is the
  canonical name of the platform under which \R was compiled.
  
  \code{\link{.Machine}} for details of the arithmetic used, and
  \code{\link{system}} for invoking platform-specific system commands.
}

\examples{
## Note: this can be done in a system-independent way
## by file.info()$isdir
if(.Platform$OS.type == "unix") {
   system.test <- function(...) { system(paste("test", ...)) == 0 }
   dir.exists <- function(dir)
Radford Neal's avatar
Radford Neal committed
97
       sapply(dir, function(d) system.test("-d", d))
Radford Neal's avatar
Radford Neal committed
98 99 100 101 102
   dir.exists(c(R.home(), "/tmp", "~", "/NO"))# > T T T F
}
}
\keyword{file}
\keyword{utilities}