Skip to content

Commit

Permalink
factor out function used to resolve "auto" download method
Browse files Browse the repository at this point in the history
  • Loading branch information
jjallaire committed Jul 2, 2015
1 parent a939166 commit 0aceed7
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions src/cpp/r/R/Tools.R
Expand Up @@ -687,18 +687,23 @@ assign(envir = .rs.Env, ".rs.getVar", function(name)
}
})

.rs.addFunction("autoDownloadMethod", function() {
if (capabilities("http/ftp"))
"internal"
else if (nzchar(Sys.which("wget")))
"wget"
else if (nzchar(Sys.which("curl")))
"curl"
else
""
})

.rs.addFunction("isDownloadMethodSecure", function(method) {

# resolve auto if needed
if (identical(method, "auto")) {
if (capabilities("http/ftp"))
method <- "internal"
else if (nzchar(Sys.which("wget")))
method <- "wget"
else if (nzchar(Sys.which("curl")))
method <- "curl"
}

if (identical(method, "auto"))
method <- .rs.autoDownloadMethod()

# check for methods known to work securely
if (method %in% c("wininet", "libcurl", "wget", "curl")) {
TRUE
Expand Down

0 comments on commit 0aceed7

Please sign in to comment.