Rebol 编程/read-thru
外观
< Rebol 编程
READ-THRU url /progress callback /update /expand /check info /to local-file
从磁盘缓存中读取网络文件。返回二进制数据,否则在错误时返回无。
READ-THRU 是一个函数值。
- url -- (类型:url 文件)
- /progress
- callback -- 在传输过程中调用 func [总字节]。返回 true。 (类型:任何)
- /update -- 强制从源站点更新。
- /expand -- 传输后自动解压缩。
- /check -- 仅当版本、校验和/安全或日期/大小不匹配时更新。
- info -- (类型:任何)
- /to -- 指定文件目标,而不是缓存。
- local-file -- (类型:文件无)
read-thru: func [ {Read a net file from thru the disk cache. Returns binary, else none on error.} url [url! file!] /progress callback {Call func [total bytes] during transfer. Return true.} /update "Force update from source site" /expand "Auto-decompress after transfer." /check {Update only if version, checksum/secure, or date/size do not match.} info /to "Specify a file target, not cache." local-file [file! none!] /local file data purl loc-path ][ vbug ['read-thru url info update] if none? file: path-thru url [return none] if local-file [file: local-file] if all [not update exists-thru?/check file info] [ if error? try [data: read/binary file] [return none] return data ] if file? url [ return attempt [read/binary url] ] loc-path: first split-path file if data: read-net/progress url :callback [ if not exists? loc-path [ if error? try [make-dir/deep loc-path] [return none] ] if all [expand find/match data "rebpress"] [ if error? try [data: decompress skip data 8] [return none] ] write/binary file data if all [check block? info info/2] [ error? try [set-modes file [modification-date: info/2]] ] ] vbug ['read-thru-ok? found? data] data ]