1212# ' @export
1313# ' @example
1414# ' R/examples/example.R
15- setCacheDir = function (cacheDir ) {
16- options(RCACHE.DIR = cacheDir )
17- }
15+ setCacheDir = function (cacheDir = NULL ) { .setDir(" RCACHE.DIR" , cacheDir ) }
16+
17+ # ' Fetcher of the currently set cache directory.
18+ # '
19+ # ' \code{getCacheDir} retrieves the value of the option that stores the currently
20+ # ' set cache directory path.
21+ # '
22+ # ' @return If the option is set, the path to the currently set cache directory; otherwise, \code{NULL}.
23+ # ' @export
24+ getCacheDir = function () { getOption(" RCACHE.DIR" ) }
1825
1926# ' Set shared cache directory
2027# '
@@ -24,25 +31,21 @@ setCacheDir = function(cacheDir) {
2431# '
2532# ' @param sharedCacheDir Directory where shared caches should be stored
2633# ' @export
27- setSharedCacheDir = function (sharedCacheDir ) {
28- options(RESOURCES.RCACHE = sharedCacheDir )
29- }
34+ setSharedCacheDir = function (sharedCacheDir = NULL ) { .setDir(" RESOURCES.RCACHE" , sharedCacheDir ) }
3035
3136# ' Sets local cache build directory with scripts for building files.
3237# '
3338# ' @param cacheBuildDir Directory where build scripts are stored.
3439# ' @export
35- setCacheBuildDir = function (cacheBuildDir ) {
36- options(RBUILD.DIR = cacheBuildDir )
37- }
40+ setCacheBuildDir = function (cacheBuildDir = NULL ) { .setDir(" RBUILD.DIR" , cacheBuildDir ) }
3841
3942# ' View simpleCache options
4043# '
4144# ' Views simpleCache global variables
4245# ' @export
4346simpleCacheOptions = function () {
4447 message(" RESOURCES.RCACHE:\t " , getOption(" RESOURCES.RCACHE" ))
45- message(" RCACHE.DIR:\t " , getOption( " RCACHE.DIR " ))
48+ message(" RCACHE.DIR:\t " , getCacheDir( ))
4649 message(" RBUILD.DIR:\t " , getOption(" RBUILD.DIR" ))
4750 message(" SIMPLECACHE.ENV:\t " , getOption(" SIMPLECACHE.ENV" ))
4851}
@@ -66,3 +69,9 @@ resetCacheSearchEnvironment = function() {
6669 options(SIMPLECACHE.ENV = NULL )
6770}
6871
72+
73+ .setDir = function (optname , dirpath = NULL ) {
74+ diropts = list (ifelse(is.null(dirpath ), getwd(), dirpath ))
75+ names(diropts ) = optname
76+ do.call(options , diropts )
77+ }
0 commit comments