R/path_to_disks.R

Defines functions disk_error_message check_ESS_webpages check_i check_t

Documented in check_ESS_webpages check_i check_t disk_error_message

##' check_t
##'
##' @return potentially an error
check_t <- function() {
    check_disk <- any(names(Sys.getenv()) == "path_to_t_disk")

    if(!check_disk) {
        stop(disk_error_message("'t'", "'/media/t'", "'t:/'"))
    }
}

##' check_i
##'
##' @return potentially an error
check_i <- function() {
    check_disk <- any(names(Sys.getenv()) == "path_to_i_disk")

    if(!check_disk) {
        stop(disk_error_message("'i'", "'/media/i'", "'i:/'"))
    }
}

##' check_ESS_webpages
##'
##' @return potentially an error
check_ESS_webpages <- function() {
    check_disk <- any(names(Sys.getenv()) == "path_to_ESS_webpages")

    if(!check_disk) {
        stop(disk_error_message("'ESS_webpages'", "'/media/ESS_webpages'", "'z:/'"))
    }
}

##' disk_error_message
##'
##' @return A character vector
##' @param name A string discribing the disk
##' @param path1 An example of the path on linux
##' @param path2 And example of the path on windows
disk_error_message <- function(name, path1, path2) {
    paste0("\n\nIn order to find the path to the ",
           name,
           " disk which holds certain files\n",
           "needed by the package, you need to ",
           "set the R environment varible:\n",
           "'path_to_t_disk'. \n",
           "You do that by creating a file in your home directory\n",
           "or in the current working directory named\n",
           "'.Renviron' with something like the following line:\n",
           "\n",
           "path_to_t_disk = ", path1,"\n",
           "\n",
           "OR perhaps:\n",
           "\n",
           "path_to_t_disk = ", path2, "\n")
}
SVA-SE/svamap documentation built on Sept. 25, 2020, 3:53 p.m.