Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

How to copy file ?

 [1/8] from: patrick::philipot::laposte::net at: 11-Oct-2003 10:09


Hi List, Wanting to copy a file from one folder to another I found only this : ; copy rebol logo write/binary to-file rejoin [image-dir %pwr-reb-tech100.gif] read/binary %pwr-reb-tech100.gif I am surprised not to find a "file copying" command, or have I not search enough? Regards Patrick

 [2/8] from: AJMartin:orcon at: 24-Dec-2003 22:39


Patrick wrote:
> I am surprised not to find a "file copying" command
I'm fairly sure there isn't one. You can always write your own. Here's a simplistic version: File-Copy: func [Destination [file! url!] Source [file! url!]] [ write/binary Destination read/binary Source ] And use it like: File-Copy to-file rejoin [image-dir %pwr-reb-tech100.gif] %pwr-reb-tech100.gif But, as you can see it doesn't really save that much over the individual 'write and 'read words and is less versatile. And if one needs to do anything special with the files (like using one of the refinements of 'read or 'write, the above function is useless. Andrew J Martin Grail Jedi ICQ: 26227169 http://www.rebol.it/Valley/ http://valley.orcon.net.nz/ http://Valley.150m.com/

 [3/8] from: carl:cybercraft at: 24-Dec-2003 22:39


On 11-Oct-03, Patrick Philipot wrote:
> Hi List, > Wanting to copy a file from one folder to another I found only
<<quoted lines omitted: 4>>
> I am surprised not to find a "file copying" command, or have I not > search enough?
I think you've searched enough, as I don't think there is one. I guess RT hasn't bothered because it's so simple using write. ie... write %new-file read %original-file Obviously you'd use write's refinements as required. And also obviously it's a simple matter to code a function to do it, but should the function include a check for over-writing another file or not? And an option to rename the file? Best I think for the programmers to write such a function based on their individual needs. -- Carl Read

 [4/8] from: andreas:bolka:gmx at: 11-Oct-2003 14:03


Saturday, October 11, 2003, 10:20:13 AM, A wrote:
> Patrick wrote: >> I am surprised not to find a "file copying" command
<<quoted lines omitted: 3>>
> write/binary Destination read/binary Source > ]
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). -- Best regards, Andreas

 [5/8] 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 size). dcopy: function [ source-file [file!] "Source file" target-file [file!] "Target file" ][ source-port target-port data ][ ; 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 ] close source-port close target-port ][ write/binary target-file read/binary source-file ] ; Reclaim used memory recycle ] Regards, Ashley

 [6/8] from: andreas:bolka:gmx at: 12-Oct-2003 14:24


Sunday, October 12, 2003, 4:11:01 AM, Ashley wrote:
>> 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
<<quoted lines omitted: 4>>
> answer. I use the following function to copy files to a DVD (2048 > being the 2Kb DVD block size).
dcopy: function [ source-file [file!] "Source file" target-file [file!] "Target file" ]
<snip>
thanks ashley, that looks good! -- Best regards, Andreas

 [7/8] from: warp:reboot:ch at: 13-Oct-2003 10:50


you can find copy-file function here: http://reboot.ch/rebol/file-copy.r does buffered copy but use rename when possible Will Arp [warp--reboot--ch]

 [8/8] from: g:santilli:tiscalinet:it at: 13-Oct-2003 11:41


Hi Andreas, On Saturday, October 11, 2003, 2:03:57 PM, you wrote: AB> the problem with copying files that way, is that it doesn't seem to AB> really scale. i.e. it seems to be impossible to copy a 600mb file AB> (rebol crashes, at least on win32 the last time i tried). Did you try: file-copy: func [dest src /local data] [ dest: open/binary/direct/write/new dest src: open/binary/direct/read src while [data: copy/part src 1048576] [ insert dest data ] close dest close src ] (not tested, but should work as I'm doing something very similar in file-sync.r). Regards, Gabriele. -- Gabriele Santilli <[g--santilli--tiscalinet--it]> -- REBOL Programmer Amiga Group Italia sez. L'Aquila --- SOON: http://www.rebol.it/

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted