Skip to content

Commit 4628a39

Browse files
tar - Ticket [65767447de] - EF - Added gzip support based on patch by Christian Werner, with thanks.
Internal refactoring to be more clear wrt semantics. Docs added. Docs regenerated. Bumped to version 0.13.
1 parent a8cf61d commit 4628a39

File tree

6 files changed

+396
-184
lines changed

6 files changed

+396
-184
lines changed

embedded/md/tcllib/files/modules/tar/tar.md

+26-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
[//000000001]: # (tar \- Tar file handling)
33
[//000000002]: # (Generated from file 'tar\.man' by tcllib/doctools with format 'markdown')
4-
[//000000003]: # (tar\(n\) 0\.12\.1 tcllib "Tar file handling")
4+
[//000000003]: # (tar\(n\) 0\.13 tcllib "Tar file handling")
55

66
<hr> [ <a href="../../../../toc.md">Main Table Of Contents</a> &#124; <a
77
href="../../../toc.md">Table Of Contents</a> &#124; <a
@@ -35,12 +35,12 @@ tar \- Tar file creation, extraction & manipulation
3535
# <a name='synopsis'></a>SYNOPSIS
3636

3737
package require Tcl 8\.5 9
38-
package require tar ?0\.12\.1?
38+
package require tar ?0\.13?
3939

40-
[__::tar::contents__ *tarball* ?__\-chan__?](#1)
41-
[__::tar::stat__ *tarball* ?file? ?__\-chan__?](#2)
40+
[__::tar::contents__ *tarball* ?__\-chan__? ?__\-gzip__?](#1)
41+
[__::tar::stat__ *tarball* ?file? ?__\-chan__? ?__\-gzip__?](#2)
4242
[__::tar::untar__ *tarball* *args*](#3)
43-
[__::tar::get__ *tarball* *fileName* ?__\-chan__?](#4)
43+
[__::tar::get__ *tarball* *fileName* ?__\-chan__? ?__\-gzip__?](#4)
4444
[__::tar::create__ *tarball* *files* *args*](#5)
4545
[__::tar::add__ *tarball* *files* *args*](#6)
4646
[__::tar::remove__ *tarball* *files*](#7)
@@ -78,9 +78,27 @@ For all commands, when using __\-chan__ \.\.\.
7878
unstack the transformation before seeking the channel back to a suitable
7979
position, and \(b\) for restacking it after\.
8080

81+
Regarding support for gzip compression:
82+
83+
1. Errors are thrown when attempting to read from compressed tar archives
84+
while compression support \(i\.e\. __::zlib__\) is not available\.
85+
86+
1. Errors are thrown when attempting to read an uncompressed tar archive when
87+
compression is requested by the user \(__\-gzip__\)\.
88+
89+
No errors are thrown when attempting to read a compressed tar archive when
90+
compression was not requested, and is supported\. In that case the commands
91+
automatically activate the code handling the compression\.
92+
93+
1. Errors are thrown when attempting to edit compressed tar archives\. See the
94+
commands __tar::add__, and __tar::remove__\. This is not supported\.
95+
96+
1. Creation of compressed tar archives however is supported, as this
97+
sequentially writes the archive, allowing for streaming compression\.
98+
8199
# <a name='section3'></a>COMMANDS
82100

83-
- <a name='1'></a>__::tar::contents__ *tarball* ?__\-chan__?
101+
- <a name='1'></a>__::tar::contents__ *tarball* ?__\-chan__? ?__\-gzip__?
84102

85103
Returns a list of the files contained in *tarball*\. The order is not
86104
sorted and depends on the order files were stored in the archive\.
@@ -89,7 +107,7 @@ For all commands, when using __\-chan__ \.\.\.
89107
channel\. It is assumed that the channel was opened for reading, and
90108
configured for binary input\. The command will *not* close the channel\.
91109

92-
- <a name='2'></a>__::tar::stat__ *tarball* ?file? ?__\-chan__?
110+
- <a name='2'></a>__::tar::stat__ *tarball* ?file? ?__\-chan__? ?__\-gzip__?
93111

94112
Returns a nested dict containing information on the named ?file? in
95113
*tarball*, or all files if none is specified\. The top level are pairs of
@@ -151,7 +169,7 @@ For all commands, when using __\-chan__ \.\.\.
151169
puts "Extracted $file ($size bytes)"
152170
}
153171

154-
- <a name='4'></a>__::tar::get__ *tarball* *fileName* ?__\-chan__?
172+
- <a name='4'></a>__::tar::get__ *tarball* *fileName* ?__\-chan__? ?__\-gzip__?
155173

156174
Returns the contents of *fileName* from the *tarball*\.
157175

idoc/man/files/modules/tar/tar.n

+27-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'\"
22
'\" Generated from file 'tar\&.man' by tcllib/doctools with format 'nroff'
33
'\"
4-
.TH "tar" n 0\&.12\&.1 tcllib "Tar file handling"
4+
.TH "tar" n 0\&.13 tcllib "Tar file handling"
55
.\" The -*- nroff -*- definitions below are for supplemental macros used
66
.\" in Tcl/Tk manual entries.
77
.\"
@@ -275,15 +275,15 @@ tar \- Tar file creation, extraction & manipulation
275275
.SH SYNOPSIS
276276
package require \fBTcl 8\&.5 9\fR
277277
.sp
278-
package require \fBtar ?0\&.12\&.1?\fR
278+
package require \fBtar ?0\&.13?\fR
279279
.sp
280-
\fB::tar::contents\fR \fItarball\fR ?\fB-chan\fR?
280+
\fB::tar::contents\fR \fItarball\fR ?\fB-chan\fR? ?\fB-gzip\fR?
281281
.sp
282-
\fB::tar::stat\fR \fItarball\fR ?file? ?\fB-chan\fR?
282+
\fB::tar::stat\fR \fItarball\fR ?file? ?\fB-chan\fR? ?\fB-gzip\fR?
283283
.sp
284284
\fB::tar::untar\fR \fItarball\fR \fIargs\fR
285285
.sp
286-
\fB::tar::get\fR \fItarball\fR \fIfileName\fR ?\fB-chan\fR?
286+
\fB::tar::get\fR \fItarball\fR \fIfileName\fR ?\fB-chan\fR? ?\fB-gzip\fR?
287287
.sp
288288
\fB::tar::create\fR \fItarball\fR \fIfiles\fR \fIargs\fR
289289
.sp
@@ -324,17 +324,36 @@ example \fBgunzip\fR, then it is the responsibility of the user to (a)
324324
unstack the transformation before seeking the channel back to a suitable
325325
position, and (b) for restacking it after\&.
326326
.PP
327+
Regarding support for gzip compression:
328+
.IP [1]
329+
Errors are thrown when attempting to read from compressed tar archives
330+
while compression support (i\&.e\&. \fB::zlib\fR) is not available\&.
331+
.IP [2]
332+
Errors are thrown when attempting to read an uncompressed tar archive
333+
when compression is requested by the user (\fB-gzip\fR)\&.
334+
.sp
335+
No errors are thrown when attempting to read a compressed tar archive
336+
when compression was not requested, and is supported\&. In that case the
337+
commands automatically activate the code handling the compression\&.
338+
.IP [3]
339+
Errors are thrown when attempting to edit compressed tar archives\&.
340+
See the commands \fBtar::add\fR, and \fBtar::remove\fR\&.
341+
This is not supported\&.
342+
.IP [4]
343+
Creation of compressed tar archives however is supported, as this
344+
sequentially writes the archive, allowing for streaming compression\&.
345+
.PP
327346
.SH COMMANDS
328347
.TP
329-
\fB::tar::contents\fR \fItarball\fR ?\fB-chan\fR?
348+
\fB::tar::contents\fR \fItarball\fR ?\fB-chan\fR? ?\fB-gzip\fR?
330349
Returns a list of the files contained in \fItarball\fR\&. The order is not sorted and depends on the order
331350
files were stored in the archive\&.
332351
.sp
333352
If the option \fB-chan\fR is present \fItarball\fR is interpreted as an open channel\&.
334353
It is assumed that the channel was opened for reading, and configured for binary input\&.
335354
The command will \fInot\fR close the channel\&.
336355
.TP
337-
\fB::tar::stat\fR \fItarball\fR ?file? ?\fB-chan\fR?
356+
\fB::tar::stat\fR \fItarball\fR ?file? ?\fB-chan\fR? ?\fB-gzip\fR?
338357
Returns a nested dict containing information on the named ?file? in \fItarball\fR,
339358
or all files if none is specified\&. The top level are pairs of filename and info\&. The info is a dict with the keys
340359
"\fBmode\fR \fBuid\fR \fBgid\fR \fBsize\fR \fBmtime\fR \fBtype\fR \fBlinkname\fR \fBuname\fR \fBgname\fR
@@ -394,7 +413,7 @@ puts "Extracted $file ($size bytes)"
394413

395414
.CE
396415
.TP
397-
\fB::tar::get\fR \fItarball\fR \fIfileName\fR ?\fB-chan\fR?
416+
\fB::tar::get\fR \fItarball\fR \fIfileName\fR ?\fB-chan\fR? ?\fB-gzip\fR?
398417
Returns the contents of \fIfileName\fR from the \fItarball\fR\&.
399418
.sp
400419
.CS

idoc/www/tcllib/files/modules/tar/tar.html

+23-8
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@
107107
&#124; <a href="../../../../toc2.html">Applications</a>
108108
] <hr>
109109
<div class="doctools">
110-
<h1 class="doctools_title">tar(n) 0.12.1 tcllib &quot;Tar file handling&quot;</h1>
110+
<h1 class="doctools_title">tar(n) 0.13 tcllib &quot;Tar file handling&quot;</h1>
111111
<div id="name" class="doctools_section"><h2><a name="name">Name</a></h2>
112112
<p>tar - Tar file creation, extraction &amp; manipulation</p>
113113
</div>
@@ -127,13 +127,13 @@ <h1 class="doctools_title">tar(n) 0.12.1 tcllib &quot;Tar file handling&quot;</h
127127
<div class="doctools_synopsis">
128128
<ul class="doctools_requirements">
129129
<li>package require <b class="pkgname">Tcl 8.5 9</b></li>
130-
<li>package require <b class="pkgname">tar <span class="opt">?0.12.1?</span></b></li>
130+
<li>package require <b class="pkgname">tar <span class="opt">?0.13?</span></b></li>
131131
</ul>
132132
<ul class="doctools_syntax">
133-
<li><a href="#1"><b class="cmd">::tar::contents</b> <i class="arg">tarball</i> <span class="opt">?<b class="option">-chan</b>?</span></a></li>
134-
<li><a href="#2"><b class="cmd">::tar::stat</b> <i class="arg">tarball</i> <span class="opt">?file?</span> <span class="opt">?<b class="option">-chan</b>?</span></a></li>
133+
<li><a href="#1"><b class="cmd">::tar::contents</b> <i class="arg">tarball</i> <span class="opt">?<b class="option">-chan</b>?</span> <span class="opt">?<b class="option">-gzip</b>?</span></a></li>
134+
<li><a href="#2"><b class="cmd">::tar::stat</b> <i class="arg">tarball</i> <span class="opt">?file?</span> <span class="opt">?<b class="option">-chan</b>?</span> <span class="opt">?<b class="option">-gzip</b>?</span></a></li>
135135
<li><a href="#3"><b class="cmd">::tar::untar</b> <i class="arg">tarball</i> <i class="arg">args</i></a></li>
136-
<li><a href="#4"><b class="cmd">::tar::get</b> <i class="arg">tarball</i> <i class="arg">fileName</i> <span class="opt">?<b class="option">-chan</b>?</span></a></li>
136+
<li><a href="#4"><b class="cmd">::tar::get</b> <i class="arg">tarball</i> <i class="arg">fileName</i> <span class="opt">?<b class="option">-chan</b>?</span> <span class="opt">?<b class="option">-gzip</b>?</span></a></li>
137137
<li><a href="#5"><b class="cmd">::tar::create</b> <i class="arg">tarball</i> <i class="arg">files</i> <i class="arg">args</i></a></li>
138138
<li><a href="#6"><b class="cmd">::tar::add</b> <i class="arg">tarball</i> <i class="arg">files</i> <i class="arg">args</i></a></li>
139139
<li><a href="#7"><b class="cmd">::tar::remove</b> <i class="arg">tarball</i> <i class="arg">files</i></a></li>
@@ -165,16 +165,31 @@ <h1 class="doctools_title">tar(n) 0.12.1 tcllib &quot;Tar file handling&quot;</h
165165
unstack the transformation before seeking the channel back to a suitable
166166
position, and (b) for restacking it after.</p></li>
167167
</ol>
168+
<p>Regarding support for gzip compression:</p>
169+
<ol class="doctools_enumerated">
170+
<li><p>Errors are thrown when attempting to read from compressed tar archives
171+
while compression support (i.e. <b class="cmd">::zlib</b>) is not available.</p></li>
172+
<li><p>Errors are thrown when attempting to read an uncompressed tar archive
173+
when compression is requested by the user (<b class="option">-gzip</b>).</p>
174+
<p>No errors are thrown when attempting to read a compressed tar archive
175+
when compression was not requested, and is supported. In that case the
176+
commands automatically activate the code handling the compression.</p></li>
177+
<li><p>Errors are thrown when attempting to edit compressed tar archives.
178+
See the commands <b class="cmd">tar::add</b>, and <b class="cmd">tar::remove</b>.
179+
This is not supported.</p></li>
180+
<li><p>Creation of compressed tar archives however is supported, as this
181+
sequentially writes the archive, allowing for streaming compression.</p></li>
182+
</ol>
168183
</div>
169184
<div id="section3" class="doctools_section"><h2><a name="section3">COMMANDS</a></h2>
170185
<dl class="doctools_definitions">
171-
<dt><a name="1"><b class="cmd">::tar::contents</b> <i class="arg">tarball</i> <span class="opt">?<b class="option">-chan</b>?</span></a></dt>
186+
<dt><a name="1"><b class="cmd">::tar::contents</b> <i class="arg">tarball</i> <span class="opt">?<b class="option">-chan</b>?</span> <span class="opt">?<b class="option">-gzip</b>?</span></a></dt>
172187
<dd><p>Returns a list of the files contained in <i class="arg">tarball</i>. The order is not sorted and depends on the order
173188
files were stored in the archive.</p>
174189
<p>If the option <b class="option">-chan</b> is present <i class="arg">tarball</i> is interpreted as an open channel.
175190
It is assumed that the channel was opened for reading, and configured for binary input.
176191
The command will <em>not</em> close the channel.</p></dd>
177-
<dt><a name="2"><b class="cmd">::tar::stat</b> <i class="arg">tarball</i> <span class="opt">?file?</span> <span class="opt">?<b class="option">-chan</b>?</span></a></dt>
192+
<dt><a name="2"><b class="cmd">::tar::stat</b> <i class="arg">tarball</i> <span class="opt">?file?</span> <span class="opt">?<b class="option">-chan</b>?</span> <span class="opt">?<b class="option">-gzip</b>?</span></a></dt>
178193
<dd><p>Returns a nested dict containing information on the named <span class="opt">?file?</span> in <i class="arg">tarball</i>,
179194
or all files if none is specified. The top level are pairs of filename and info. The info is a dict with the keys
180195
&quot;<b class="const">mode</b> <b class="const">uid</b> <b class="const">gid</b> <b class="const">size</b> <b class="const">mtime</b> <b class="const">type</b> <b class="const">linkname</b> <b class="const">uname</b> <b class="const">gname</b>
@@ -218,7 +233,7 @@ <h1 class="doctools_title">tar(n) 0.12.1 tcllib &quot;Tar file handling&quot;</h
218233
}
219234
</pre>
220235
</dd>
221-
<dt><a name="4"><b class="cmd">::tar::get</b> <i class="arg">tarball</i> <i class="arg">fileName</i> <span class="opt">?<b class="option">-chan</b>?</span></a></dt>
236+
<dt><a name="4"><b class="cmd">::tar::get</b> <i class="arg">tarball</i> <i class="arg">fileName</i> <span class="opt">?<b class="option">-chan</b>?</span> <span class="opt">?<b class="option">-gzip</b>?</span></a></dt>
222237
<dd><p>Returns the contents of <i class="arg">fileName</i> from the <i class="arg">tarball</i>.</p>
223238
<pre class="doctools_example">
224239
% set readme [::tar::get tarball.tar doc/README] {

modules/tar/pkgIndex.tcl

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
if {![package vsatisfies [package provide Tcl] 8.5 9]} { return }
2-
package ifneeded tar 0.12.1 [list source [file join $dir tar.tcl]]
2+
package ifneeded tar 0.13 [list source [file join $dir tar.tcl]]

modules/tar/tar.man

+28-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[comment {-*- mode: tcl ; fill-column: 80 -*- doctools manpage}]
2-
[vset PACKAGE_VERSION 0.12.1]
2+
[vset PACKAGE_VERSION 0.13]
33
[manpage_begin tar n [vset PACKAGE_VERSION]]
44
[keywords archive]
55
[keywords {tape archive}]
@@ -15,7 +15,7 @@
1515
(contents, stats, get, untar) support the GNU LongName extension (header type
1616
'L') for large paths.
1717

18-
[para]
18+
[para]
1919

2020
[section BEWARE]
2121

@@ -48,11 +48,34 @@ For all commands, when using [option -chan] ...
4848

4949
[list_end]
5050

51+
Regarding support for gzip compression:
52+
53+
[list_begin enumerated]
54+
55+
[enum] Errors are thrown when attempting to read from compressed tar archives
56+
while compression support (i.e. [cmd ::zlib]) is not available.
57+
58+
[enum] Errors are thrown when attempting to read an uncompressed tar archive
59+
when compression is requested by the user ([option -gzip]).
60+
61+
[para] No errors are thrown when attempting to read a compressed tar archive
62+
when compression was not requested, and is supported. In that case the
63+
commands automatically activate the code handling the compression.
64+
65+
[enum] Errors are thrown when attempting to edit compressed tar archives.
66+
See the commands [cmd tar::add], and [cmd tar::remove].
67+
This is not supported.
68+
69+
[enum] Creation of compressed tar archives however is supported, as this
70+
sequentially writes the archive, allowing for streaming compression.
71+
72+
[list_end]
73+
5174
[section COMMANDS]
5275

5376
[list_begin definitions]
5477

55-
[call [cmd ::tar::contents] [arg tarball] [opt [option -chan]]]
78+
[call [cmd ::tar::contents] [arg tarball] [opt [option -chan]] [opt [option -gzip]]]
5679

5780
Returns a list of the files contained in [arg tarball]. The order is not sorted and depends on the order
5881
files were stored in the archive.
@@ -62,7 +85,7 @@ If the option [option -chan] is present [arg tarball] is interpreted as an open
6285
It is assumed that the channel was opened for reading, and configured for binary input.
6386
The command will [emph not] close the channel.
6487

65-
[call [cmd ::tar::stat] [arg tarball] [opt file] [opt [option -chan]]]
88+
[call [cmd ::tar::stat] [arg tarball] [opt file] [opt [option -chan]] [opt [option -gzip]]]
6689

6790
Returns a nested dict containing information on the named [opt file] in [arg tarball],
6891
or all files if none is specified. The top level are pairs of filename and info. The info is a dict with the keys
@@ -117,7 +140,7 @@ puts "Extracted $file ($size bytes)"
117140
}
118141
}]
119142

120-
[call [cmd ::tar::get] [arg tarball] [arg fileName] [opt [option -chan]]]
143+
[call [cmd ::tar::get] [arg tarball] [arg fileName] [opt [option -chan]] [opt [option -gzip]]]
121144

122145
Returns the contents of [arg fileName] from the [arg tarball].
123146

0 commit comments

Comments
 (0)