【发布时间】:2015-06-29 19:21:09
【问题描述】:
我正在尝试使用download.file 下载以下数据集,该数据集仅在method = "wget" 时有效)
# Doesn't work
download.file('http://uofi.box.com/shared/static/bba3968d7c3397c024ec.dta', tempfile(), method = "auto")
download.file('http://uofi.box.com/shared/static/bba3968d7c3397c024ec.dta', tempfile(), method = "curl")
# Works
download.file('http://uofi.box.com/shared/static/bba3968d7c3397c024ec.dta', tempfile(), method = "wget")
根据help(download.file),
如果选择了method = "auto"(默认),内部方法是 为 file:// URL 和其他提供的 URL 选择 能力(“http/ftp”)是真的(几乎总是这样)。
看源码,“内部方法”指的是:
if (method == "internal") {
status <- .External(C_download, url, destfile, quiet,
mode, cacheOK)
if (!quiet)
flush.console()
}
但是,我仍然不知道.External(C_download) 做了什么,尤其是跨平台。知道这一点对我来说很重要,而不是依赖 wget,因为我正在编写一个可以跨平台工作的包。
【问题讨论】:
-
我认为这是指为您的操作系统配置的方法。例如,它可能是
curl。 -
看函数定义。非常清楚当您调用不同的
method值时发生了什么。 -
@RomanLuštrik 感谢您指出来源。很明显
method = "auto"调用了.External(C_download),但此时我又被难住了。如何知道这个外部函数是做什么的? (找到.Internal()和.Primitive()的C 代码会容易得多)