#' Ensure gzip support is available for reading .gz files
#'
#' Internal helper used by both .tidy_dt() and .create_rast().
#'
#' Aborts if .gz files are present and neither R.utils nor system gzip
#' is available.
#'
#' @param files Character vector of file paths.
#' @returns An invisible `TRUE` if support is found.
#' @dev

.check_gzip_support <- function(files) {
  if (!is.character(files) || !any(endsWith(files, ".gz"))) {
    return(invisible(TRUE))
  }

  if (
    !requireNamespace("R.utils", quietly = TRUE) &&
      Sys.which("gzip") == ""
  ) {
    cli::cli_abort(
      c(
        x = "Cannot read compressed `.gz` files.",
        i = "Package {.pkg R.utils} is not installed.",
        i = "System {.code gzip} command not found.",
        i = "Install {.pkg R.utils} with {.code install.packages('R.utils')}."
      )
    )
  }

  invisible(TRUE)
}
