[ALLY] Bug in read-thru ?
[1/1] from: larry::ecotope::com at: 13-Apr-2001 11:37
Just noticed a possible bug or oversight in the View 1.0 read-thru function.
The source is copied below. The help line states that read-thru returns
binary. This is true if the url arg is of type url! but not if it is of type
file!. See the first line of code in the func body.
It seems to me that read-thru should return the same datatype for both file!
and url!. This is easily fixed by changing the first line to
if file? url [return read/binary url]
-Larry
---------------------------------------------------
>> source read-thru
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"
/to "Specify local file target." local-file [file! none!]
/local file data purl loc-path
][
if file? url [return read url]
if not all [purl: decode-url url purl/target purl/host] [return none]
loc-path: rejoin [system/options/home/public slash purl/host slash any
[purl/path ""]]
file: join loc-path purl/target
if local-file [file: local-file loc-path: first split-path file]
either all [not update exists? file] [data: read/binary file] [
if data: read-net/progress url :callback [
if not exists? loc-path [make-dir/deep loc-path]
write/binary file data
]
]
data
]