unrar: Extract files from 'rar' archives (only works on Linux)

View source: R/unrar.R

unrarR Documentation

Extract files from rar archives (only works on Linux)

Description

This function extract files from a .rar file

Usage

unrar(
  file,
  dest_dir = fs::path_ext_remove(file),
  overwrite = FALSE,
  quiet = TRUE
)

Arguments

file

a file path to a file.rar

dest_dir

path to extract files. Defaults to dirname(file).

overwrite

logical, use overwrite = TRUE to overwrite existing files.

quiet

Hide printed output, messages, warnings, and errors (TRUE, the default), or display them as they occur?

Details

This function has the side effect of extract files in a directory named (dest_dir/basename(file)) when dest_dir is not NULL.

Value

character vector with files path

Note

This function is a wrapper to call unrar command. It is required you have unrar Linux library installed. You can install it with ⁠apt install unrar⁠.

Examples

## Not run: 
if (interactive()) {

  rarfile_url <- paste0("https://www.dropbox.com/scl/fi/63eimy6j2ok1q3vf11zs4/",
  "some-file.rar?rlkey=jhveob9ysl1ivy3alnt68c61g&st=dvt43nb1&dl=1")

  dest_file <- file.path(tempdir(), strsplit(basename(rarfile_url), "\\?")[[1]][[1]])
  #dest_file <- tempfile(fileext = ".rar")
  download.file(rarfile_url, dest_file, mode = "wb")
  extracted_files <- unrar(dest_file)
  extracted_files
}

## End(Not run)

lhmet/lhmetools documentation built on July 26, 2024, 1:48 p.m.