zip-utils {usethis}R Documentation

Download and unpack a ZIP file

Description

Functions to download and unpack a ZIP file into a local folder of files, with very intentional default behaviour. Useful in pedagogical settings or anytime you need a large audience to download a set of files quickly and actually be able to find them.

Usage

use_course(url, destdir = NULL)

use_zip(url, destdir = getwd(), cleanup = if (interactive()) NA else
  FALSE)

Arguments

url

Link to a ZIP file containing the materials. Various short forms are accepted, to reduce the typing burden in live settings:

* bit.ly or rstd.io shortlinks: "bit.ly/xxx-yyy-zzz" or "rstd.io/foofy"
* GitHub repo spec: "OWNER/REPO"

Function works well with DropBox folders and GitHub repos, but should work for ZIP files generally. See examples and use_course_details for more.

destdir

The new folder is stored here. If NULL, defaults to user's Desktop or some other conspicuous place.

cleanup

Whether to delete the original ZIP file after unpacking its contents. In an interactive setting, NA leads to a menu where user can approve the deletion (or decline).

Value

Path to the new directory holding the unpacked ZIP file, invisibly.

Functions

Examples

## Not run: 
# download the source of usethis from GitHub, behind a bit.ly shortlink
use_course("bit.ly/usethis-shortlink-example")
use_course("http://bit.ly/usethis-shortlink-example")

## download the source of rematch2 package, from CRAN and GitHub
use_course("https://cran.r-project.org/bin/windows/contrib/3.4/rematch2_2.0.1.zip")

## from GitHub, 3 ways
use_course("r-lib/rematch2")
use_course("https://github.com/r-lib/rematch2/archive/master.zip")
use_course("https://api.github.com/repos/r-lib/rematch2/zipball/master")

## End(Not run)

[Package usethis version 1.5.1 Index]