Tcl Library Source Code

Check-in [5f3611f96a]
Login
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to [email protected]
or submit via the online form by Sep 9.

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Zip - Mkzip - Tkt [b9725d990b] Fix handling of directories with leading dash ('-') in their name. Version bump 1.2.1 - B (mkzip) - T (mkzip, NEW)
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 5f3611f96af9f901bef566abf2f55a36d6c8ea4660e283c9bda7d21648cfed21
User & Date: aku 2019-04-15 23:13:23
References
2019-04-15
23:14 Closed ticket [b9725d990b]: ::zipfile::mkzip::walk fails with directory names preceded with '-' plus 6 other changes artifact: 49e904047e user: aku
Context
2019-04-15
23:19
math - math::exact - Tkt [30526e9027] - Fix version mismatch of code vs. index check-in: 068c2af6e8 user: aku tags: trunk
23:13
Zip - Mkzip - Tkt [b9725d990b] Fix handling of directories with leading dash ('-') in their name. Version bump 1.2.1 - B (mkzip) - T (mkzip, NEW) check-in: 5f3611f96a user: aku tags: trunk
19:22
virtchannel-base, tcl::chan::cat - Tkt [1975182bdd] Fixed non-functional event handling of the channel. Version bump 1.0.3 - B (tcl::chan::cat) - T (tcl::chan::cat, NEW) check-in: aeb3bec0da user: aku tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to embedded/md/tcllib/files/modules/zip/mkzip.md.

1
2
3
4
5
6
7
8
9
10
11
12
..
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
[//000000001]: # (zipfile::mkzip \- Zip archive creation)
[//000000002]: # (Generated from file 'mkzip\.man' by tcllib/doctools with format 'markdown')
[//000000003]: # (Copyright © 2009 Pat Thoyts)
[//000000004]: # (zipfile::mkzip\(n\) 1\.2 tcllib "Zip archive creation")

<hr> [ <a href="../../../../toc.md">Main Table Of Contents</a> &#124; <a
href="../../../toc.md">Table Of Contents</a> &#124; <a
href="../../../../index.md">Keyword Index</a> &#124; <a
href="../../../../toc0.md">Categories</a> &#124; <a
href="../../../../toc1.md">Modules</a> &#124; <a
href="../../../../toc2.md">Applications</a> ] <hr>
................................................................................
  - [Category](#category)

  - [Copyright](#copyright)

# <a name='synopsis'></a>SYNOPSIS

package require Tcl 8\.6  
package require zipfile::mkzip ?1\.2?  

[__::zipfile::mkzip::mkzip__ *zipfile* ?__\-zipkit__? ?__\-runtime__ *prefix*? ?__\-comment__ *string*? ?__\-directory__ *rootpath*? ?__\-exclude__ *exclude*? ?__\-\-__? ?*path*\.\.\.?](#1)  

# <a name='description'></a>DESCRIPTION

This package utilizes the zlib functions in Tcl 8\.6 to build zip archives\.




|







 







|







1
2
3
4
5
6
7
8
9
10
11
12
..
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
[//000000001]: # (zipfile::mkzip \- Zip archive creation)
[//000000002]: # (Generated from file 'mkzip\.man' by tcllib/doctools with format 'markdown')
[//000000003]: # (Copyright &copy; 2009 Pat Thoyts)
[//000000004]: # (zipfile::mkzip\(n\) 1\.2\.1 tcllib "Zip archive creation")

<hr> [ <a href="../../../../toc.md">Main Table Of Contents</a> &#124; <a
href="../../../toc.md">Table Of Contents</a> &#124; <a
href="../../../../index.md">Keyword Index</a> &#124; <a
href="../../../../toc0.md">Categories</a> &#124; <a
href="../../../../toc1.md">Modules</a> &#124; <a
href="../../../../toc2.md">Applications</a> ] <hr>
................................................................................
  - [Category](#category)

  - [Copyright](#copyright)

# <a name='synopsis'></a>SYNOPSIS

package require Tcl 8\.6  
package require zipfile::mkzip ?1\.2\.1?  

[__::zipfile::mkzip::mkzip__ *zipfile* ?__\-zipkit__? ?__\-runtime__ *prefix*? ?__\-comment__ *string*? ?__\-directory__ *rootpath*? ?__\-exclude__ *exclude*? ?__\-\-__? ?*path*\.\.\.?](#1)  

# <a name='description'></a>DESCRIPTION

This package utilizes the zlib functions in Tcl 8\.6 to build zip archives\.

Changes to idoc/man/files/modules/zip/mkzip.n.

1
2
3
4
5
6
7
8
9
10
11
12
...
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
'\"
'\" Generated from file 'mkzip\&.man' by tcllib/doctools with format 'nroff'
'\" Copyright (c) 2009 Pat Thoyts
'\"
.TH "zipfile::mkzip" n 1\&.2 tcllib "Zip archive creation"
.\" The -*- nroff -*- definitions below are for supplemental macros used
.\" in Tcl/Tk manual entries.
.\"
.\" .AP type name in/out ?indent?
.\"	Start paragraph describing an argument to a library procedure.
.\"	type is type of argument (int, etc.), in/out is either "in", "out",
.\"	or "in/out" to describe whether procedure reads or modifies arg,
................................................................................
..
.BS
.SH NAME
zipfile::mkzip \- Build a zip archive
.SH SYNOPSIS
package require \fBTcl  8\&.6\fR
.sp
package require \fBzipfile::mkzip  ?1\&.2?\fR
.sp
\fB::zipfile::mkzip::mkzip\fR \fIzipfile\fR ?\fB-zipkit\fR? ?\fB-runtime\fR \fIprefix\fR? ?\fB-comment\fR \fIstring\fR? ?\fB-directory\fR \fIrootpath\fR? ?\fB-exclude\fR \fIexclude\fR? ?\fB--\fR? ?\fIpath\fR\&.\&.\&.?
.sp
.BE
.SH DESCRIPTION
.PP
This package utilizes the zlib functions in Tcl 8\&.6 to build zip



|







 







|







1
2
3
4
5
6
7
8
9
10
11
12
...
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
'\"
'\" Generated from file 'mkzip\&.man' by tcllib/doctools with format 'nroff'
'\" Copyright (c) 2009 Pat Thoyts
'\"
.TH "zipfile::mkzip" n 1\&.2\&.1 tcllib "Zip archive creation"
.\" The -*- nroff -*- definitions below are for supplemental macros used
.\" in Tcl/Tk manual entries.
.\"
.\" .AP type name in/out ?indent?
.\"	Start paragraph describing an argument to a library procedure.
.\"	type is type of argument (int, etc.), in/out is either "in", "out",
.\"	or "in/out" to describe whether procedure reads or modifies arg,
................................................................................
..
.BS
.SH NAME
zipfile::mkzip \- Build a zip archive
.SH SYNOPSIS
package require \fBTcl  8\&.6\fR
.sp
package require \fBzipfile::mkzip  ?1\&.2\&.1?\fR
.sp
\fB::zipfile::mkzip::mkzip\fR \fIzipfile\fR ?\fB-zipkit\fR? ?\fB-runtime\fR \fIprefix\fR? ?\fB-comment\fR \fIstring\fR? ?\fB-directory\fR \fIrootpath\fR? ?\fB-exclude\fR \fIexclude\fR? ?\fB--\fR? ?\fIpath\fR\&.\&.\&.?
.sp
.BE
.SH DESCRIPTION
.PP
This package utilizes the zlib functions in Tcl 8\&.6 to build zip

Changes to idoc/www/tcllib/files/modules/zip/mkzip.html.

103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
...
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
&#124; <a href="../../../toc.html">Table Of Contents</a>
&#124; <a href="../../../../index.html">Keyword Index</a>
&#124; <a href="../../../../toc0.html">Categories</a>
&#124; <a href="../../../../toc1.html">Modules</a>
&#124; <a href="../../../../toc2.html">Applications</a>
 ] <hr>
<div class="doctools">
<h1 class="doctools_title">zipfile::mkzip(n) 1.2 tcllib &quot;Zip archive creation&quot;</h1>
<div id="name" class="doctools_section"><h2><a name="name">Name</a></h2>
<p>zipfile::mkzip - Build a zip archive</p>
</div>
<div id="toc" class="doctools_section"><h2><a name="toc">Table Of Contents</a></h2>
<ul class="doctools_toc">
<li class="doctools_section"><a href="#toc">Table Of Contents</a></li>
<li class="doctools_section"><a href="#synopsis">Synopsis</a></li>
................................................................................
<li class="doctools_section"><a href="#copyright">Copyright</a></li>
</ul>
</div>
<div id="synopsis" class="doctools_section"><h2><a name="synopsis">Synopsis</a></h2>
<div class="doctools_synopsis">
<ul class="doctools_requirements">
<li>package require <b class="pkgname">Tcl 8.6</b></li>
<li>package require <b class="pkgname">zipfile::mkzip <span class="opt">?1.2?</span></b></li>
</ul>
<ul class="doctools_syntax">
<li><a href="#1"><b class="cmd">::zipfile::mkzip::mkzip</b> <i class="arg">zipfile</i> <span class="opt">?<b class="option">-zipkit</b>?</span> <span class="opt">?<b class="option">-runtime</b> <i class="arg">prefix</i>?</span> <span class="opt">?<b class="option">-comment</b> <i class="arg">string</i>?</span> <span class="opt">?<b class="option">-directory</b> <i class="arg">rootpath</i>?</span> <span class="opt">?<b class="option">-exclude</b> <i class="arg">exclude</i>?</span> <span class="opt">?<b class="option">--</b>?</span> <span class="opt">?<i class="arg">path</i>...?</span></a></li>
</ul>
</div>
</div>
<div id="section1" class="doctools_section"><h2><a name="section1">Description</a></h2>






|







 







|







103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
...
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
&#124; <a href="../../../toc.html">Table Of Contents</a>
&#124; <a href="../../../../index.html">Keyword Index</a>
&#124; <a href="../../../../toc0.html">Categories</a>
&#124; <a href="../../../../toc1.html">Modules</a>
&#124; <a href="../../../../toc2.html">Applications</a>
 ] <hr>
<div class="doctools">
<h1 class="doctools_title">zipfile::mkzip(n) 1.2.1 tcllib &quot;Zip archive creation&quot;</h1>
<div id="name" class="doctools_section"><h2><a name="name">Name</a></h2>
<p>zipfile::mkzip - Build a zip archive</p>
</div>
<div id="toc" class="doctools_section"><h2><a name="toc">Table Of Contents</a></h2>
<ul class="doctools_toc">
<li class="doctools_section"><a href="#toc">Table Of Contents</a></li>
<li class="doctools_section"><a href="#synopsis">Synopsis</a></li>
................................................................................
<li class="doctools_section"><a href="#copyright">Copyright</a></li>
</ul>
</div>
<div id="synopsis" class="doctools_section"><h2><a name="synopsis">Synopsis</a></h2>
<div class="doctools_synopsis">
<ul class="doctools_requirements">
<li>package require <b class="pkgname">Tcl 8.6</b></li>
<li>package require <b class="pkgname">zipfile::mkzip <span class="opt">?1.2.1?</span></b></li>
</ul>
<ul class="doctools_syntax">
<li><a href="#1"><b class="cmd">::zipfile::mkzip::mkzip</b> <i class="arg">zipfile</i> <span class="opt">?<b class="option">-zipkit</b>?</span> <span class="opt">?<b class="option">-runtime</b> <i class="arg">prefix</i>?</span> <span class="opt">?<b class="option">-comment</b> <i class="arg">string</i>?</span> <span class="opt">?<b class="option">-directory</b> <i class="arg">rootpath</i>?</span> <span class="opt">?<b class="option">-exclude</b> <i class="arg">exclude</i>?</span> <span class="opt">?<b class="option">--</b>?</span> <span class="opt">?<i class="arg">path</i>...?</span></a></li>
</ul>
</div>
</div>
<div id="section1" class="doctools_section"><h2><a name="section1">Description</a></h2>

Changes to modules/zip/mkzip.man.

1
2
3
4
5
6
7
8
[vset ZIP_mkzip_VERSION 1.2]
[comment {-*- tcl -*- doctools manpage}]
[manpage_begin zipfile::mkzip n [vset ZIP_mkzip_VERSION]]
[keywords decompression zip]
[copyright {2009 Pat Thoyts}]
[moddesc {Zip archive creation}]
[titledesc {Build a zip archive}]
[category  File]
|







1
2
3
4
5
6
7
8
[vset ZIP_mkzip_VERSION 1.2.1]
[comment {-*- tcl -*- doctools manpage}]
[manpage_begin zipfile::mkzip n [vset ZIP_mkzip_VERSION]]
[keywords decompression zip]
[copyright {2009 Pat Thoyts}]
[moddesc {Zip archive creation}]
[titledesc {Build a zip archive}]
[category  File]

Changes to modules/zip/mkzip.tcl.

5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
..
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
...
275
276
277
278
279
280
281
282
#
# Create a zipkit using mkzip filename.zkit -zipkit -directory xyz.vfs
# or a zipfile using mkzip filename.zip -directory dirname -exclude "*~"
#
## BSD License
##
# Package providing commands for the generation of a zip archive.
# version 1.2

package require Tcl 8.6

namespace eval ::zipfile {}
namespace eval ::zipfile::decode {}
namespace eval ::zipfile::encode {}
namespace eval ::zipfile::mkzip {}
................................................................................
#        a set of glob expressions to match against files and to avoid.
#        The match arg is internal.
#        eg: walk library {CVS/* *~ .#*} to exclude CVS and emacs cruft.
#
proc ::zipfile::mkzip::walk {base {excludes ""} {match *} {path {}}} {
    set result {}
    set imatch [file join $path $match]
    set files [glob -nocomplain -tails -types f -directory $base $imatch]
    foreach file $files {
        set excluded 0
        foreach glob $excludes {
            if {[string match $glob $file]} {
                set excluded 1
                break
            }
        }
        if {!$excluded} {lappend result $file}
    }
    foreach dir [glob -nocomplain -tails -types d -directory $base $imatch] {
        set subdir [walk $base $excludes $match $dir]
        if {[llength $subdir]>0} {
            set result [concat $result [list $dir] $subdir]
        }
    }
    return $result
}
................................................................................
  close $zf

  return
}

# ### ### ### ######### ######### #########
## Ready
package provide zipfile::mkzip 1.2






|







 







|










|







 







|
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
..
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
...
275
276
277
278
279
280
281
282
#
# Create a zipkit using mkzip filename.zkit -zipkit -directory xyz.vfs
# or a zipfile using mkzip filename.zip -directory dirname -exclude "*~"
#
## BSD License
##
# Package providing commands for the generation of a zip archive.
# version 1.2.1

package require Tcl 8.6

namespace eval ::zipfile {}
namespace eval ::zipfile::decode {}
namespace eval ::zipfile::encode {}
namespace eval ::zipfile::mkzip {}
................................................................................
#        a set of glob expressions to match against files and to avoid.
#        The match arg is internal.
#        eg: walk library {CVS/* *~ .#*} to exclude CVS and emacs cruft.
#
proc ::zipfile::mkzip::walk {base {excludes ""} {match *} {path {}}} {
    set result {}
    set imatch [file join $path $match]
    set files [glob -nocomplain -tails -types f -directory $base -- $imatch]
    foreach file $files {
        set excluded 0
        foreach glob $excludes {
            if {[string match $glob $file]} {
                set excluded 1
                break
            }
        }
        if {!$excluded} {lappend result $file}
    }
    foreach dir [glob -nocomplain -tails -types d -directory $base -- $imatch] {
        set subdir [walk $base $excludes $match $dir]
        if {[llength $subdir]>0} {
            set result [concat $result [list $dir] $subdir]
        }
    }
    return $result
}
................................................................................
  close $zf

  return
}

# ### ### ### ######### ######### #########
## Ready
package provide zipfile::mkzip 1.2.1

Added modules/zip/mkzip.test.
















































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# mkzip.test - Copyright (C) 2019 Andreas Kupries <[email protected]>

# -------------------------------------------------------------------------

source [file join \
	[file dirname [file dirname [file join [pwd] [info script]]]] \
	devtools testutilities.tcl]

testsNeedTcl     8.6
testsNeedTcltest 2

testing {
    useLocal mkzip.tcl zipfile::mkzip
}

# -------------------------------------------------------------------------

test zipfile-mkzip-mkzip-1.0 {mkzip, wrong args, not enough} -body {
    zipfile::mkzip::mkzip
} -returnCodes error -result {wrong # args: should be "zipfile::mkzip::mkzip filename ?arg ...?"}

test zipfile-mkzip-mkzip-2.0 {mkzip, tkt b9725d990b} -setup {
    tcltest::makeDirectory foo
    tcltest::makeDirectory foo/-1
} -cleanup {
    tcltest::removeDirectory foo
    file delete foo.zip
} -body {
    zipfile::mkzip::mkzip foo.zip -directory foo
} -result {}

# -------------------------------------------------------------------------

testsuiteCleanup

# -------------------------------------------------------------------------
# Local Variables:
#   mode: tcl
#   indent-tabs-mode: nil
# End:

Changes to modules/zip/pkgIndex.tcl.

1
2
3
4
5
6
7
8
if {![package vsatisfies [package provide Tcl] 8.4]} {return}

package ifneeded zipfile::decode 0.7.1 [list source [file join $dir decode.tcl]]
package ifneeded zipfile::encode 0.4   [list source [file join $dir encode.tcl]]

if {![package vsatisfies [package provide Tcl] 8.6]} {return}

package ifneeded zipfile::mkzip 1.2 [list source [file join $dir mkzip.tcl]]






|
1
2
3
4
5
6
7
8
if {![package vsatisfies [package provide Tcl] 8.4]} {return}

package ifneeded zipfile::decode 0.7.1 [list source [file join $dir decode.tcl]]
package ifneeded zipfile::encode 0.4   [list source [file join $dir encode.tcl]]

if {![package vsatisfies [package provide Tcl] 8.6]} {return}

package ifneeded zipfile::mkzip 1.2.1 [list source [file join $dir mkzip.tcl]]