download: Download File

Description Usage Arguments Details Value Note See Also Examples

View source: R/download.R

Description

Download a file in binary mode, e.g. a model executable.

Usage

1
2
download(url, dir = ".", mode = "wb", chmod = file_ext(url) == "",
  destfile = file.path(dir, basename(url)), quiet = TRUE, ...)

Arguments

url

URL of file to download.

dir

directory to download to.

mode

download mode, see details.

chmod

whether to set execute permission (default is TRUE if file has no filename extension).

destfile

destination path and filename (optional, overrides dir).

quiet

whether to suppress messages.

...

passed to download.file.

Details

With the default mode "wb" the file is downloaded in binary mode (see download.file), to prevent R from adding ^M at line ends. This is particularly relevant for Windows model executables, while the chmod switch is useful when downloading Linux executables.

This function can be convenient for downloading any file, including text files. Data files in CSV or other text format can also be read directly into memory using read.table, read.taf or similar functions, without writing to the file system.

Value

No return value, called for side effects.

Note

If destfile contains a question mark it is removed from the destfile filename. Similarly, if destfile contains spaces or ‘%20’ sequences, those are converted to underscores.

In general, TAF scripts do not access the internet using download or similar functions. Instead, data and software are declared in DATA.bib and SOFTWARE.bib and then downloaded using taf.bootstrap. The exception is when a bootstrap script is used to fetch files from a web service (see TAF Wiki).

See Also

download.file is the underlying base function to download files.

download.github downloads a GitHub repository.

TAF-package gives an overview of the package.

Examples

1
2
3
4
5
6
## Not run: 
url <- paste0("https://github.com/ices-taf/2015_had-iceg/raw/master/",
              "bootstrap/initial/software/catageysa/catageysa.exe")
download(url)

## End(Not run)

TAF documentation built on April 7, 2021, 5:06 p.m.