R/get_file_hash.R

Defines functions get_file_hash

Documented in get_file_hash

#' Calculate hash from file
#'
#' Returns the SHA1 hash of a given file
#' 
#' @keywords internal
#'
#' @param filename a \code{string} specifying a filename
#'
#' @family get functions
#'
get_file_hash <- function(filename) {
  if (!file.exists(filename))
    stop(paste0("File ", filename, " does not exist"))
  file(filename) %>%
    openssl::sha1() %>%
    as.character() %>%
    as.character()
}
ScottishCovidResponse/SCRCdataAPI documentation built on July 26, 2023, 9:47 p.m.