Comments on: 64 bit ports
The potential size of files has changed since REBOL 2.0 was released. It was once highly unlikely that you'd refer to a file larger than 2GB. These days, it's become a regular thing for many users.
The new port design of REBOL 3.0 is now 64 bit. Both the size of the file and the index into the file are 64 bit.
So, this code will work for "any size" files:
f: open/binary %from-file
t: open/binary/new %to-file
while [data: take f 100000] [append t data]
A few notes:
- What's that take function? For now, just think of it as a copy with a remove.
Unlike copy, take eats the input. This works for all series, not just ports.
(I need to discuss take in a separate article.)
- There is a subtle but important change shown here. Do you see it?
In R3, a port index is no longer part of the reference, it is part of the port value.
But, that's also the subject of another article.
cool ! :-)
although we could consider this a helper... for any buffered operations, its soooo much more explicit. I guess its native too ?
Nice example demonstrating the new native 'append as well.
The demo code will work for any size file, but without /direct or /skip, you might need a lot of memory. :)|
That is to say, handling huge files will be great, but not terribly useful without those supporting features.|
if the new ports can handle buffered I/O implicitely, its very nice... which is what the above seems to indicate since he copies a fixed amount of bytes and traverses the source.
appending it to the output (not writing the file out in one go)
Post a Comment:
You can post a comment here. Keep it on-topic.