R/try_file_remove.R

Defines functions try_file_remove

Documented in try_file_remove

#' @title Try to remove a file
#'
#' @description Tries to safely remove a file by capturing and ignoring any errors.
#' 
#' @return \code{TRUE} if the removal was successfuly, \code{FALSE} otherwise.
try_file_remove <- function(filepath) {
  tryCatch({
    fs::file_delete(filepath)
    TRUE
  }, error = function(e) {
    FALSE
  })
}
mmuurr/s3io documentation built on Jan. 5, 2023, 2:19 p.m.