File: getOperatingSystem.R

package info (click to toggle)
r-cran-bbmisc 1.13.1-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,256 kB
  • sloc: ansic: 176; sh: 9; makefile: 5
file content (40 lines) | stat: -rw-r--r-- 1,121 bytes parent folder | download
1
2
3
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
#' @title Functions to determine the operating system
#'
#' @description
#' \describe{
#' \item{getOperatingSystem}{Simple wrapper for \code{.Platform$OS.type}, returns \code{character(1)}.}
#' \item{isUnix}{Predicate for OS string, returns \code{logical(1)}. Currently this would include Unix, Linux and Mac flavours.}
#' \item{isLinux}{Predicate for sysname string, returns \code{logical(1)}.}
#' \item{isDarwin}{Predicate for sysname string, returns \code{logical(1)}.}
#' \item{isWindows}{Predicate for OS string, returns \code{logical(1)}.}
#' }
#'
#' @return See above.
#' @export
getOperatingSystem = function() {
  .Platform$OS.type
}

#' @rdname getOperatingSystem
#' @export
isWindows = function() {
  .Platform$OS.type == "windows"
}

#' @rdname getOperatingSystem
#' @export
isUnix = function() {
  .Platform$OS.type == "unix"
}

#' @rdname getOperatingSystem
#' @export
isLinux = function() {
  isUnix() && grepl("linux", Sys.info()["sysname"], ignore.case = TRUE)
}

#' @rdname getOperatingSystem
#' @export
isDarwin = function() {
  isUnix() && grepl("darwin", Sys.info()["sysname"], ignore.case = TRUE)
}