Jump to content

Rebol Programming/load-thru

From Wikibooks, open books for an open world

USAGE:

[edit | edit source]
LOAD-THRU url /update /binary /to local-file /all /expand /check info 

DESCRIPTION:

[edit | edit source]

Load a net file from the disk cache.

LOAD-THRU is a function value.

ARGUMENTS:

[edit | edit source]
  • url -- (Type: url file)

REFINEMENTS:

[edit | edit source]
  • /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 | edit source]
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
]