From 7ee047d2d5c47c270b9fef9565edaf4dcdca8e81 Mon Sep 17 00:00:00 2001 From: Jack Wasey Date: Tue, 26 May 2020 06:43:37 -0400 Subject: [PATCH] clean-up R_user_dir should use 'cache' not 'data'. On Windows, 'data' goes in Roaming profile, and I do not want to dump hundreds of Mb there. --- DESCRIPTION | 2 +- R/R_user_dir.R | 24 ++++++++++++++++++------ tools/extra-tests.R | 1 + 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 5c566611..20a8c66b 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -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.")) diff --git a/R/R_user_dir.R b/R/R_user_dir.R index 912938b9..4f323a0d 100644 --- a/R/R_user_dir.R +++ b/R/R_user_dir.R @@ -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) diff --git a/tools/extra-tests.R b/tools/extra-tests.R index bed8a4fd..4f02eb56 100644 --- a/tools/extra-tests.R +++ b/tools/extra-tests.R @@ -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('.')