Skip to contents

Creates and initializes a directory structure for caching ExploreCourses XML data. This function ensures a consistent location for storing cached course and department data between sessions. If no cache directory is specified, it creates a default directory named 'explorecourses_cache' in the current working directory.

Usage

init_cache_dir(cache_dir = NULL)

Arguments

cache_dir

Character string. Optional path to the desired cache directory. If NULL (default), uses '{working_directory}/explorecourses_cache'.

Value

Character string containing the path to the initialized cache directory.

Details

The function performs the following operations:

  • If cache_dir is NULL, constructs default path using DEFAULT_CACHE_DIR

  • Creates the directory if it doesn't exist (including parent directories)

  • Ensures the directory is writable

  • Returns the full path to the created/existing directory

The function uses fs::dir_create() which is safe for concurrent access and handles nested directory creation automatically.

Error handling

If directory creation fails due to permissions or other filesystem errors. The error will include the attempted path and specific error message.

See also

Examples

if (FALSE) { # \dontrun{
# Use default cache location
cache_dir <- init_cache_dir()

# Specify custom cache location
cache_dir <- init_cache_dir("~/my_course_cache")
} # }