Skip to content

Commit

Permalink
clean-up R_user_dir
Browse files Browse the repository at this point in the history
should use 'cache' not 'data'. On Windows, 'data' goes in Roaming profile, and I do not want to dump hundreds of Mb there.
  • Loading branch information
Jack Wasey committed May 26, 2020
1 parent 4d93e01 commit 7ee047d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Authors@R:
family = "Lang",
role = "aut",
email = "michellang@gmail.com",
comment = "backport of R_user-dir for R version >4. ORCID = 0000-0001-9754-0393"),
comment = "backport of R_user_dir for R version >4. ORCID = 0000-0001-9754-0393"),
person(given = "R Core Team",
role = c("aut", "cph"),
comment = "utils::askYesNo backport and m4 script for OpenMP detection."))
Expand Down
24 changes: 18 additions & 6 deletions R/R_user_dir.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,29 @@
#' See the original description in \code{tools::R_user_dir}.
#'
#' @keywords internal
#' @rawNamespace if (getRversion() < "4.0.0") export(R_user_dir)
#' @examples
#' \dontrun{
#' # get function from namespace instead of possibly getting
#' # implementation shipped with recent R versions:
#' bp_R_user_dir = getFromNamespace("R_user_dir", "backports")
#'
#' bp_R_user_dir("backports")
#' @author Michael Lang
#' f = getFromNamespace("R_user_dir", "icd")
#' cached <- f("icd", "cache")
#' confd <- f("icd", "config")
#' datad <- f("icd", "data")
#' dir.exists(c(cached, confd, datad))
#' prnts <- vapply(c(cached, confd, datad), dirname, character(1))
#' dir.exists(prnts)
#' p_prt <- vapply(prnts, dirname, character(1))
#' dir.exists(p_prt)
#' q_prt <- vapply(p_prt, dirname, character(1))
#' dir.exists(q_prt)
#' r_prt <- vapply(q_prt, dirname, character(1))
#' dir.exists(r_prt)
#' vapply(list(prnts, p_prt, q_prt, r_prt), `[[`, FUN.VALUE = character(1), 1)
#' }
#' @author Michael Lang, adapted by Jack Wasey
#' @keywords internal
#' @noRd
R_user_dir <- function(package, which = c("data", "config", "cache")) {
R_user_dir <- function(package = "icd", which = c("data", "config", "cache")) {
stopifnot(is.character(package), length(package) == 1L)

which <- match.arg(which)
Expand Down
1 change: 1 addition & 0 deletions tools/extra-tests.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ release_sanity_checks <- function() {
message("Missing NAMESPACE S3")
s <- devtools::missing_s3(); if (length(s)) s
message("style check")
# exclude R_user_dir.R so easier to diff with upstream
styler::style_pkg(exclude_files = c("R/RcppExports.R", "R/R_user_dir.R"), dry = "fail")
message("spelling")
aspell_package_Rd_files('.')
Expand Down

0 comments on commit 7ee047d

Please # to comment.