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

  1. emiliano@cacharro:~$ cat test.tcl
  2. set fname bigfile
  3.  
  4. proc CopyMore {in out chunk bytes {error {}}} {
  5. global total done
  6. incr total $bytes
  7. if {([string length $error] != 0) || [eof $in]} {
  8. set done $total
  9. close $in
  10. close $out
  11. } else {
  12. puts -nonewline $total\r
  13. fcopy $in $out -size $chunk \
  14. -command [list CopyMore $in $out $chunk]
  15. }
  16. }
  17.  
  18. set in [open $fname]
  19. set out [open $fname.copy w]
  20. set chunk 1024
  21. set total 0
  22. fcopy $in $out -size $chunk -command [list CopyMore $in $out $chunk]
  23. vwait done
  24.  
  25. puts [file size $fname]
  26. puts [file size $fname.copy]
  27. emiliano@cacharro:~$ tclsh8.5 test.tcl
  28. 91952129
  29. 91950716
  30. 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]