R/internal-system.R

Defines functions .sysDict .platform .osId .isBuilder .arch

#' Architecture string
#'
#' @note Updated 2023-10-17.
#' @noRd
.arch <- function() {
    switch(
        EXPR = R.Version()[["arch"]],
        "aarch64" = "arm64",
        "x86_64" = "amd64"
    )
}



#' Is the R session inside a koopa builder instance?
#'
#' @note Updated 2022-10-06.
#' @noRd
.isBuilder <- function() {
    isTRUE(nzchar(Sys.getenv("KOOPA_BUILDER")))
}



#' Operating system identifier string
#'
#' @note Updated 2023-10-17.
#' @noRd
.osId <- function() {
    paste(.platform(), .arch(), sep = "-")
}



#' Platform string
#'
#' @note Updated 2022-08-25.
#' @noRd
#'
#' @details
#' May need to update this approach in the future to support `"fedora"`,
#' `"debian"`, `"ubuntu"`, etc.
#'
#' @return `character(1)`.
.platform <- function() {
    ifelse(
        test = isMacos(),
        yes = "macos",
        no = "linux"
    )
}



#' System dictionary (for JSON parsing)
#'
#' @note Updated 2023-10-17.
#' @noRd
.sysDict <- function() {
    list(
        "optPrefix" = koopaOptPrefix(),
        "osId" = .osId(),
        "prefix" = koopaPrefix()
    )
}
acidgenomics/r-koopa documentation built on Oct. 31, 2023, 9:21 a.m.