R/utils.R

Defines functions check_mdb_tools has_mdb_tools

has_mdb_tools <- function() {
  try <- suppressWarnings(tryCatch(
    expr = system2(
      command = Sys.which("mdb-ver"),
      args = "-M",
      stderr = TRUE,
      stdout = TRUE
    ),
    error = function(e) return(NULL)
  ))
  if (is.null(try)) {
    return(FALSE)
  } else {
    stats::setNames(TRUE, try)
  }
}

check_mdb_tools <- function() {
  if (isFALSE(has_mdb_tools())) {
    msg <- c(
      "MDB Tools are not installed",
      "See: https://github.com/mdbtools/mdbtools",
      "* Debian: apt install mdbtools",
      "* Homebrew: brew install mdbtools"
    )
    stop(paste(msg, collapse = "\n"), call. = FALSE)
  }
}

Try the mdbr package in your browser

Any scripts or data that you put into this service are public.

mdbr documentation built on May 29, 2024, 7:27 a.m.