The code below is a minor adaption of the tar::create procedure. It adds the option -progress <name of callback function> that will update a progress bar.
proc ::tar::create {tar files args} {
set dereference 0
set chan 0
set gzip 0
set progress ""
parseOpts {dereference 0 chan 0 gzip 0 progress 1} $args
lassign [SetupCreation $chan $gzip $tar] fh pos
set files [recurseDirs $files $dereference]
if {$progress!=""} {
set count [llength $files]
eval [concat $progress $count 0]
set i 0
}
foreach x $files {
writefile $x $fh $dereference $x
if {$gzip} {
chan configure $fh -flush sync
}
if {$progress!=""} {
incr i
eval [concat $progress $count $i]
}
}
if {$progress!=""} {
eval [concat $progress 0 0]
}
puts -nonewline $fh [string repeat \x00 1024]
Close $fh $pos $chan $gzip
return $tar
}
|