| config_dir {toscutil} | R Documentation |
Get Normalized Configuration Directory Path of a Program
Description
config_dir returns the absolute, normalized path to the configuration directory of a program/package/app based on an optional app-specific commandline argument, an optional app-specific environment variable and the XDG Base Directory Specification
Usage
config_dir(
app_name,
cl_arg = commandArgs()[grep("--config-dir", commandArgs()) + 1],
env_var = Sys.getenv(toupper(paste0(app_name, "_config_dir()"))),
create = FALSE,
sep = "/"
)
Arguments
app_name |
Name of the program/package/app |
cl_arg |
Value of app specific commandline parameter |
env_var |
Value of app specific environment variable |
create |
whether to create returned path, if it doesn't exists yet |
sep |
Path separator to be used on Windows |
Details
The following algorithm is used to determine the location of the configuration directory for application $app_name:
If parameter
cl_argis a non-empty string, return itElse, if parameter
env_varis a non-empty string, return itElse, if environment variable (EV)
XDG_CONFIG_HOMEexists, return$XDG_CONFIG_HOME/$app_nameElse, if EV
HOMEexists, return$HOME/.config/{app_name}Else, if EV
USERPROFILEexists, return$USERPROFILE/.config/{app_name}Else, return
$WD/.config/{app-name}
where $WD equals the current working directory and the notation $VAR is used to specify the value of a parameter or environment variable VAR.
Value
Normalized path to the configuration directory of $app_name.
See Also
data_dir(), config_file(), xdg_config_home()
Examples
config_dir("myApp")