R/file_read.R

Defines functions file_read

Documented in file_read

#' @rdname file_connections
#' @export
file_read <- function(file, mode = "r", filter = NULL, options = character(), password = NA_character_) {
  options <- validate_options(options)

  if (!inherits(file, "connection")) {
    # `raw = TRUE` disables R's own magic-number detection
    file <- file(file, raw = TRUE)
  }

  description <- glue::glue("file_read({desc})", desc = summary(file)$description)

  archive_read_(file, 1L, description, mode, archive_formats()["raw"], archive_filters()[filter], options, c(password), sz = 2^14)
}

Try the archive package in your browser

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

archive documentation built on July 30, 2026, 5:09 p.m.