R/temp.R

Defines functions renv_tempdir_path renv_tempdir_path_impl renv_tempfile_path

renv_tempfile_path <- function(pattern = "renv-",
                                 tmpdir = renv_tempdir_path(),
                                 fileext = "")
{
  path <- tempfile(pattern, tmpdir, fileext)
  norm <- renv_file_normalize(path, winslash = "/")
  defer(unlink(norm, recursive = TRUE, force = TRUE), envir = parent.frame())
  norm
}

renv_tempdir_path_impl <- function() {
  dir <- Sys.getenv("RENV_TEMPDIR", unset = tempfile("renv-tempdir-"))
  dir.create(dir, recursive = TRUE, showWarnings = FALSE)
  Sys.chmod(dir, mode = "0700")
  dir
}

renv_tempdir_path <- function() {
  renv_global("tempdir", renv_tempdir_path_impl())
}
wnattt/renv documentation built on Dec. 23, 2021, 5:19 p.m.