Rebol Programming/load-thru

USAGE:

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

DESCRIPTION:

edit

Load a net file from the disk cache.

LOAD-THRU is a function value.

ARGUMENTS:

edit
  • url -- (Type: url file)

REFINEMENTS:

edit
  • /update -- Force update from source site
  • /binary -- Force binary mode, otherwise expects REBOL data or code.
  • /to -- Specify local file target.
    • local-file -- (Type: 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 -- (Type: any)

SOURCE CODE

edit
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
]