Skip to contents

Returns the path to the cache directory used by pr_get_tree() and pr_date_tree() when called with cache = TRUE. Pass a path to override the default.

Usage

pr_tree_cache_dir(path = NULL)

Arguments

path

A length-1 character vector or NULL. If non-NULL, sets the cache directory to path (creating it if it doesn't exist). If NULL (default), returns the currently configured directory.

Value

A length-1 character vector — the absolute path of the cache directory.

Details

The default cache directory is tools::R_user_dir() with type "cache" and the package name "prepR4pcm", which on Linux is typically ~/.cache/R/prepR4pcm/, on macOS ~/Library/Caches/org.R-project.R/R/prepR4pcm/, and on Windows something under %LOCALAPPDATA%\R\cache\R\prepR4pcm\.

To use a cache directory you control, pass its path explicitly with pr_tree_cache_dir(path).

Examples

# Default location
pr_tree_cache_dir()
#> [1] "/Users/z3437171/Library/Caches/org.R-project.R/R/prepR4pcm"

old_cache <- getOption("prepR4pcm.cache_dir", NULL)
tmp_cache <- tempfile("prepR4pcm-cache-")
pr_tree_cache_dir(tmp_cache)
options(prepR4pcm.cache_dir = old_cache)
unlink(tmp_cache, recursive = TRUE)