R/utils.R

Defines functions zip_dir with_dir `%||%`

`%||%` <- function(x, y) {
  if (is.null(x)) y else x
}


with_dir <- function(path, expr) {
  owd <- setwd(path)
  on.exit(setwd(owd))
  force(expr)
}


zip_dir <- function(path, dest = paste0(basename(path), ".zip")) {
  with_dir(dirname(path), {
    zip::zipr(dest, basename(path))
    normalizePath(dest)
  })
}
vimc/orderly.sharepoint documentation built on Aug. 5, 2023, 3:43 a.m.