[REBOL] Re: How to copy file ?
From: atruter:labyrinth:au at: 12-Oct-2003 12:11
> the problem with copying files that way, is that it doesn't seem to
> really scale. i.e. it seems to be impossible to copy a 600mb file
> (rebol crashes, at least on win32 the last time i tried).
The crash is probably due to the fact that read tries to copy the entire
600mb file into memory *before* then writing it to disk. For large files,
copying portions at a time using ports could be the answer. I use the
following function to copy files to a DVD (2048 being the 2Kb DVD block
dcopy: function [
source-file [file!] "Source file"
target-file [file!] "Target file"
; Can't open a file in use
either not none? attempt [source-port: open/binary/direct source-file][
target-port: open/binary/direct/new target-file
while [data: copy/part source-port 2048][
insert tail target-port data
write/binary target-file read/binary source-file
; Reclaim used memory