REBOL Programming/load-thru

< REBOL Programming

USAGE:

LOAD-THRU url /update /binary /to local-file /all /expand /check info 

DESCRIPTION:

Load a net file from the disk cache.

LOAD-THRU is a function value.

ARGUMENTS:

REFINEMENTS:

SOURCE CODE

load-thru: func [
    "Load a net file from the disk cache." 
    url [url! file!] 
    /update "Force update from source site" 
    /binary {Force binary mode, otherwise expects REBOL data or code.} 
    /to "Specify local file target." local-file [file! none!] 
    /all {Return block with REBOL script including unevaluated header (safe mode).} 
    /expand "Auto-decompress after transfer." 
    /check {Update only if version, checksum/secure, or date/size do not match.} info 
    /local data
][
    if not data: either update [
        read-thru/update/to/expand url local-file
    ] [
        read-thru/to/expand/check url local-file info
    ] [
        return none
    ] 
    if binary [return load data] 
    if error? try [
        data: either all [load/all to-string data] [load to-string data]
    ] [return none] 
    data
]
This article is issued from Wikibooks. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.