[REBOL] Re: Rebol doc: can't find how to copy a file ?
From: arolls:bigpond:au at: 11-May-2001 17:09
Hi,
You can use 'read and 'write. eg.
source: read %path1/file.txt
write %path2/file.txt source
or simplified:
write %path2/file.txt read %path1/file.txt
Ok, that's for text, rebol code or data.
For binary you should use /binary refinement
on both read and write. eg.
write/binary %path2/file.png read/binary %path2/file.png
If the files are on the same volume, you can use
rename. It's faster than the above method. eg.
rename %/c/path1/file.png %/c/path2/file.png
That will move it to the path2 directory.
It also works for very large files, quickly.
Files larger than memory, that need to be moved
or copied to another volume, need to be copied
in chunks. You use read/direct for that.
Various people on this list have made file/directory
utility functions, including me.
I can't remember who, but I saw someone with a
function for copying large files.
You can check out my reb-site "Anton"
http://users.bigpond.net.au/datababies/anton/rebol/index.r
and find in there dir-utils.r, in which are some nice
functions for roaming your disk. Not all are complete,
however, I think you will find 'cp (file-copy) and
'ls (directory list) useful.
Anton.