R/utils.R

Defines functions get_if_not_exists cache_path

cache_path <- function() paste0(rappdirs::user_data_dir(
  appname   = "gshhg",
  appauthor = "gshhg"), .Platform$file.sep)

get_if_not_exists <- function(url, destfile, versioned_path){
  if(!file.exists(destfile)){
    download.file(url, destfile)
    unzip(destfile, exdir = versioned_path)
  }else{
    message(paste0("A local copy of ", url, " already exists on disk"))
  }
}
jsta/gshhg documentation built on Oct. 14, 2023, 12:57 a.m.