Skip to main content

  | मौसम…

411 समाचार
Public archive edition · Attributed source reporting with original dates · AI drafts are excluded

411 REFERENCE · Wikibooks

Rebol Programming/read-thru

Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.

USAGE: READ-THRU url /progress callback /update /expand /check info /to local-file DESCRIPTION: Read a net file from thru the disk cache. Returns binary, else none on error. READ-THRU is a function value. ARGUMENTS url -- (Type: url file) REFINEMENTS /progress callback -- Call func [total bytes] during transfer. Return true. (Type: any) /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 -- (Type: any) /to -- Specify a file target, not cache. local-file -- (Type: file none) SOURCE CODE 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 ]