diff --git a/R/access.R b/R/access.R new file mode 100644 index 0000000..9dbe4d3 --- /dev/null +++ b/R/access.R @@ -0,0 +1,16 @@ +have_access <- function() { + file.access(get_lookups_dir(), 4) >= 0L +} +check_lookups_access <- function(fail_on_no_access = TRUE) { + if (!have_access()) { + no_access_msg <- c( + "x" = "You don't have the appropriate file permissions to {get_lookups_dir()}", + "i" = "Please raise a ServiceNow request for access to the UNIX acute dataset" + ) + if (fail_on_no_access) { + cli::cli_abort(no_access_msg) + } else { + cli::cli_warn(no_access_msg) + } + } +} diff --git a/R/zzz.R b/R/zzz.R new file mode 100644 index 0000000..b62ae3a --- /dev/null +++ b/R/zzz.R @@ -0,0 +1,3 @@ +.onLoad <- function(libname, pkgname) { + check_lookups_access(fail_on_no_access = FALSE) +}