From fc0b548ae5370ba1c7c7a62bdf15b4074357cf46 Mon Sep 17 00:00:00 2001 From: Eli Pousson Date: Mon, 11 Nov 2024 11:15:52 -0500 Subject: [PATCH] Fix issue w/ `get_data_dir()` --- R/standalone-get-data-dir.R | 8 +++++++- man/get_data_dir.Rd | 4 ++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/R/standalone-get-data-dir.R b/R/standalone-get-data-dir.R index 71c04e5..cb11ce3 100644 --- a/R/standalone-get-data-dir.R +++ b/R/standalone-get-data-dir.R @@ -9,6 +9,10 @@ # # ## Changelog # +# 2024-11-11: +# * Fix issue with `get_data_dir()` on Windows by setting `dir.create(recursive = +# TRUE)`. `recursive` is exposed to allow overrides. +# # 2024-09-12: # * Initial setup. # @@ -35,6 +39,7 @@ #' @param ask If `TRUE`, create is `FALSE`, and session is interactive, ask to #' create directory if the provided directory does not exist. #' @param quiet If `TRUE`, suppress informational messages. +#' @inheritParams base::dir.create #' @inheritParams rlang::args_error_context #' @export #' @importFrom cliExtras cli_yesno @@ -49,6 +54,7 @@ get_data_dir <- function(path = NULL, pkg = NULL, allow_null = TRUE, quiet = FALSE, + recursive = TRUE, call = caller_env()) { appname <- appname %||% pkg cli_quiet(quiet) @@ -99,7 +105,7 @@ get_data_dir <- function(path = NULL, "New directory created at {.file {path}}" ) - dir.create(path) + dir.create(path, recursive = recursive) invisible(path) } diff --git a/man/get_data_dir.Rd b/man/get_data_dir.Rd index ebcbac7..4eb71b4 100644 --- a/man/get_data_dir.Rd +++ b/man/get_data_dir.Rd @@ -14,6 +14,7 @@ get_data_dir( pkg = NULL, allow_null = TRUE, quiet = FALSE, + recursive = TRUE, call = caller_env() ) @@ -49,6 +50,9 @@ create directory if the provided directory does not exist.} \item{quiet}{If \code{TRUE}, suppress informational messages.} +\item{recursive}{logical. Should elements of the path other than the + last be created? If true, like the Unix command \command{mkdir -p}.} + \item{call}{The execution environment of a currently running function, e.g. \code{caller_env()}. The function will be mentioned in error messages as the source of the error. See the