R/path.R

Defines functions set_cloudstan_sys_env bin_exists bin_path default_path

Documented in bin_path default_path

.cloudstanr <- new.env(parent = emptyenv())
.cloudstanr$PATH <- NULL

#' Return the default Cloudstan CLI installation
#' path.
#'
#' @export
#'
default_path <- function() {
  file.path(Sys.getenv("HOME"), ".cloudstan")
}

#' Returns the path of the Cloudstan CLI executable.
#'
#' @export
#'
bin_path <- function() {
  p <- paste0(default_path(), "/bin/cloudstan-proxy")

  if(get_os() == "windows") {
    paste0(p, ".exe")
  } else {
    p
  }
}

bin_exists <- function() {
  file.exists(bin_path())
}

set_cloudstan_sys_env <- function() {
  Sys.setenv(CLOUDSTAN=default_path())
}
uroshercog/cloudstan-r documentation built on Dec. 23, 2021, 2:03 p.m.