R/utils.R

Defines functions is_windows is_unix is_osx is_linux is_ubuntu ensure_loaded

"%||%" <- function(x, y) if (is.null(x)) y else x

is_windows <- function() {
  identical(.Platform$OS.type, "windows")
}

is_unix <- function() {
  identical(.Platform$OS.type, "unix")
}

is_osx <- function() {
  Sys.info()["sysname"] == "Darwin"
}

is_linux <- function() {
  identical(tolower(Sys.info()[["sysname"]]), "linux")
}

is_ubuntu <- function() {
  # check /etc/lsb-release
  if (is_unix() && file.exists("/etc/lsb-release")) {
    lsbRelease <- readLines("/etc/lsb-release")
    any(grepl("Ubuntu", lsbRelease))
  } else {
    FALSE
  }
}

ensure_loaded <- function() {
  invisible(tf$`__version__`)
}
TobiasHerr/tensorflow-r-fork documentation built on May 29, 2019, 2:10 p.m.