The best way to copy a file

Discussion in 'Rebol' started by MaxV, Oct 1, 2010.

  1. MaxV

    MaxV Member

    What is the best way to copy a file?
    I want to sync 2 folders (with subfolders), but the only way that work is the following:
    http://www.rebol.com/article/0281.html
    I found it a bit complex.
    Is there a simpler way?
  2. Graham

    Graham Developer Staff Member

    That method is only really needed for large files ( many Mbs ) .. otherwise read/write/binary should be okay.
  3. notchent

    notchent Member

    Just a quick note about <i>moving</i> files (not useful in syncing, but a related topic): read/write/delete works, but rename gives MUCH faster performance.
  4. MaxV

    MaxV Member

    Why do I obtain the following error?
    Code:
    compare: func [ file1 file2][
       write/binary file1 (read/binary file2)
       ]
    
    Script Error: Cannot use insert on this type port
    ** Where: compare
    ** Near: write/binary file1 (read/binary file2)
    
  5. notchent

    notchent Member

    When you use the function, are you being sure to pass file values (%) as the parameters:
    Code:
    compare %temp1.txt %temp.txt
    
  6. Graham

    Graham Developer Staff Member

    I think it's always good practice to specify the parameter types too. The brackets are not necessary.

    Code:
    compare: func [ file1 [file!] file2 [file!] ][
       write/binary file1 read/binary file2
       ]
    

Share This Page