rappdirs (version 0.3.1)

user_cache_dir: Return full path to the user-specific cache dir for this application.

Description

Typical user cache directories are:

Usage

user_cache_dir(appname = NULL, appauthor = appname, version = NULL,
  opinion = TRUE, expand = TRUE, os = get_os())

Arguments

appname

is the name of application. If NULL, just the system directory is returned.

appauthor

(only required and used on Windows) is the name of the appauthor or distributing body for this application. Typically it is the owning company name. This falls back to appname.

version

is an optional version path element to append to the path. You might want to use this if you want multiple versions of your app to be able to run independently. If used, this would typically be "<major>.<minor>". Only applied when appname is not NULL.

opinion

(logical) can be FALSE to disable the appending of Cache to the base app data dir for Windows. See discussion below.

expand

If TRUE (the default) will expand the R_LIBS specifiers with their equivalents. See R_LIBS for list of all possibly specifiers.

os

Operating system whose conventions are used to construct the requested directory. Possible values are "win", "mac", "unix". If NULL (the default) then the convention of the current operating system (as determined by rappdirs:::get_os) will be used. This argument is unlikely to find much use outside package testing (see details section of user_data_dir).

Opinion

This function appends Cache to the `CSIDL_LOCAL_APPDATA` value. This can be disabled with opinion = FALSE option.

Details

  • Mac OS X: ~/Library/Caches/<AppName>

  • Unix: ~/.cache/<AppName>, $XDG_CACHE_HOME if defined

  • Win XP: C:\Documents and Settings\<username>\Local Settings\Application Data\<AppAuthor>\<AppName>\Cache

  • Vista: C:\Users\<username>\AppData\Local\<AppAuthor>\<AppName>\Cache

On Windows the only suggestion in the MSDN docs is that local settings go in the `CSIDL_LOCAL_APPDATA` directory. This is identical to the non-roaming app data dir (the default returned by `user_data_dir` above). Apps typically put cache data somewhere *under* the given dir here. Some examples: ...\Mozilla\Firefox\Profiles\<ProfileName>\Cache, ...\Acme\SuperApp\Cache\1.0

See Also

tempdir for a non-persistent temporary directory.

Examples

Run this code
# NOT RUN {
user_cache_dir("rappdirs")
# }
# NOT RUN {
# Throw this in your R profile to store a R history file in standard cache location
if(capabilities("cledit")) {
  cache_dir <- rappdirs::user_cache_dir("R")
  history_file <- file.path(cache_dir, "Rhistory")
  .First <- function() utils::loadhistory(history_file)
  .Last <- function() { 
    if (!file.exists(cache_dir)) dir.create(cache_dir, recursive = TRUE)
    try(savehistory(history_file))
  }
}
# }

Run the code above in your browser using DataLab