Posted to tcl by patthoyts at Thu Jan 29 12:41:26 GMT 2009view raw

  1. proc xcopy {src dest recurse {pattern *}} {
  2. file mkdir $dest
  3. foreach file [glob -nocomplain [file join $src $pattern]] {
  4. set base [file tail $file]
  5. set sub [file join $dest $base]
  6.  
  7. # Exclude CVS, SCCS, ... automatically, and possibly the temp
  8. # hierarchy itself too.
  9.  
  10. if {0 == [string compare CVS $base]} {continue}
  11. if {0 == [string compare SCCS $base]} {continue}
  12. if {0 == [string compare BitKeeper $base]} {continue}
  13. # if {[string match ${package_name}-* $base]} {continue}
  14. if {[string match *~ $base]} {continue}
  15.  
  16. if {[file isdirectory $file]} then {
  17. if {$recurse} {
  18. file mkdir $sub
  19. xcopy $file $sub $recurse $pattern
  20. }
  21. } else {
  22. puts -nonewline stdout . ; flush stdout
  23. file copy -force $file $sub
  24. }
  25. }
  26. }