4 # this file extracts a bunch of files at the end of it
7 global argv0 argv files
10 fconfigure
$fi -translation binary
11 set data
[read $fi 2000]
13 assureExists
$outdir directory
14 while { [outputOneFile
$fi $outdir] } { }
15 if {[llength
$done] > 0 } {
24 proc outputOneFile
{ stream outdir
} {
27 set exp
"\n>>>Begin (\[^ ]*) (\[0-9]+)\r?\n"
28 puts
"entering:[string length $data],[string range $data 0 200]"
29 if { [regexp
-indices $exp $data all
] } {
30 regexp
$exp $data junk filename filesize
31 set data
[string range
$data [expr 1 + [lindex
$all 1]] end
]
33 set outfile
[file join $outdir $filename]
34 assureExists
[file dirname $outfile] directory
35 set ff
[open
$outfile w
]
36 fconfigure
$ff -translation binary
39 if { [string length
$data] >= $remains } {
40 puts
-nonewline $ff [string range
$data 0 [expr $remains -1]]
41 set data
[string range
$data $remains end
]
42 lappend
done [list
$filename $filesize $outfile]
45 } else { puts
-nonewline $ff $data
46 incr remains
-[string length
$data]
47 #puts "writing [string length $data]"
50 set read [read $stream 5000]
52 if { [string length
$read] == 0 } {
55 error
"Terminates in middle of reading $filename: remains $remains"
62 proc assureExists
{ dir
type } {
63 if { [catch
{file stat
$dir stat
} ] } {
64 if { "$type" == "directory" } {
69 if { "$stat(type)" != "directory" } {
70 error
"not a $type it is a $stat(type)"
80 >>>Begin xmcd.tgz
651163