Posted to tcl by emiliano at Sun Sep 21 23:27:45 GMT 2008view pretty

emiliano@cacharro:~$ cat test.tcl 
set fname bigfile

proc CopyMore {in out chunk bytes {error {}}} {
        global total done
        incr total $bytes
        if {([string length $error] != 0) || [eof $in]} {
                set done $total
                close $in
                close $out
        } else {
                puts -nonewline $total\r
                fcopy $in $out -size $chunk \
                        -command [list CopyMore $in $out $chunk]
        }
}

set in [open $fname]
set out [open $fname.copy w]
set chunk 1024
set total 0
fcopy $in $out -size $chunk -command [list CopyMore $in $out $chunk]
vwait done

puts [file size $fname]
puts [file size $fname.copy]
emiliano@cacharro:~$ tclsh8.5 test.tcl
91952129
91950716
emiliano@cacharro:~$

Comments

Posted by emiliano at Sun Sep 21 23:33:15 GMT 2008 [text] [code]

Not a bug at all. I was copying a binary file and forgot to [fconfigure $in -translation binary; fconfigure $out -translation binary]