[REBOL] ftp dowlnoad of large file and read-io ....
From: petr::krenzelok::trz::cz at: 12-Sep-2001 13:23
Hi,
So I just rewrote core.pdf example of ftp download of large file, and it
doesn't work, unless I clear the buffer each time. What am I doing
wrong?
buf-size: 20000
buffer: make string! buf-size
source: open/direct ftp-site
target: open/new/direct join target-path [trim fl/text ".tra"]
total: 0
size: 0
start: now/time
while [not zero? size: read-io source buffer buf-size][
write-io target buffer size
clear buffer
total: total + size
p/text: to-string total
t/text: to-string now/time - start
show p show t
]
The problem is, that if I don't "clear buffer", the download of each
file stops at some 20479, and server probably closes the connection. It
even doesn't matter, if I define buffer as binary type, of size buf-size
+ 2 (btw: what is that additional 2 good for?)
Everything seems to work, once I add "clear buffer" line as above. The
question is - what is going on?
Thanks a lot,
-pekr-