Imported Upstream version 1.4.0
[platform/upstream/libzip.git] / man / ziptool.mdoc
1 .\" ziptool.mdoc -- modify zip archives in multiple ways
2 .\" Copyright (C) 2016-2017 Dieter Baron and Thomas Klausner
3 .\"
4 .\" This file is part of libzip, a library to manipulate ZIP archives.
5 .\" The authors can be contacted at <libzip@nih.at>
6 .\"
7 .\" Redistribution and use in source and binary forms, with or without
8 .\" modification, are permitted provided that the following conditions
9 .\" are met:
10 .\" 1. Redistributions of source code must retain the above copyright
11 .\"    notice, this list of conditions and the following disclaimer.
12 .\" 2. Redistributions in binary form must reproduce the above copyright
13 .\"    notice, this list of conditions and the following disclaimer in
14 .\"    the documentation and/or other materials provided with the
15 .\"    distribution.
16 .\" 3. The names of the authors may not be used to endorse or promote
17 .\"    products derived from this software without specific prior
18 .\"    written permission.
19 .\"
20 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
21 .\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22 .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
24 .\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
26 .\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
28 .\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29 .\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
30 .\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 .\"
32 .Dd December 18, 2017
33 .Dt ZIPTOOL 1
34 .Os
35 .Sh NAME
36 .Nm ziptool
37 .Nd modify zip archives
38 .Sh SYNOPSIS
39 .Nm
40 .Op Fl ceghnrst
41 .Op Fl l Ar length
42 .Op Fl o Ar offset
43 .Ar zip-archive
44 .Cm command Op Ar command-args ...
45 .Op Cm command Oo Ar command-args ... Oc ...
46 .Sh DESCRIPTION
47 .Nm
48 modifies the zip archive
49 .Ar zip-archive
50 according to the
51 .Ar commands
52 given.
53 .Pp
54 Supported options:
55 .Bl -tag -width MoMoffsetMM
56 .It Fl c
57 Check zip archive consistency when opening it.
58 .It Fl e
59 Error if archive already exists (only useful with
60 .Fl n ) .
61 .It Fl g
62 Guess file name encoding (for
63 .Cm stat
64 command).
65 .It Fl h
66 Display help.
67 .It Fl l Ar length
68 Only read
69 .Ar length
70 bytes of archive.
71 See also
72 .Fl o .
73 .It Fl n
74 Create archive if it doesn't exist.
75 See also
76 .Fl e .
77 .It Fl o Ar offset
78 Start reading input archive from
79 .Ar offset .
80 See also
81 .Fl l .
82 .It Fl r
83 Print raw file name encoding without translation (for
84 .Cm stat
85 command).
86 .It Fl s
87 Follow file name convention strictly (for
88 .Cm stat
89 command).
90 .It Fl t
91 Disregard current file contents, if any.
92 .Em Note :
93 use this with care, it deletes all existing file contents when
94 you modify the archive.
95 .El
96 .Ss Commands
97 For all commands below, the index is zero-based.
98 In other words, the first entry in the zip archive has index 0.
99 .Pp
100 Supported commands and arguments are:
101 .Bl -tag -width 10n
102 .It Cm add Ar name content
103 Add file called
104 .Ar name
105 using the string
106 .Ar content
107 from the command line as data.
108 .It Cm add_dir Ar name
109 Add directory
110 .Ar name .
111 .It Cm add_file Ar name file_to_add offset len
112 Add file
113 .Ar name
114 to archive, using
115 .Ar len
116 bytes from the file
117 .Ar file_to_add
118 as input data, starting at
119 .Ar offset .
120 .It Cm add_from_zip Ar name archivename index offset len
121 Add file called
122 .Ar name
123 to archive using data from another zip archive
124 .Ar archivename
125 using the entry with index
126 .Ar index
127 and reading
128 .Ar len
129 bytes from
130 .Ar offset .
131 .It Cm cat Ar index
132 Output file contents for entry
133 .Ar index
134 to stdout.
135 .It Cm count_extra Ar index flags
136 Print the number of extra fields for archive entry
137 .Ar index
138 using
139 .Ar flags .
140 .It Cm count_extra_by_id Ar index extra_id flags
141 Print number of extra fields of type
142 .Ar extra_id
143 for archive entry
144 .Ar index
145 using
146 .Ar flags .
147 .It Cm delete Ar index
148 Remove entry at
149 .Ar index
150 from zip archive.
151 .It Cm delete_extra Ar index extra_idx flags
152 Remove extra field number
153 .Ar extra_idx
154 from archive entry
155 .Ar index
156 using
157 .Ar flags .
158 .It Cm delete_extra_by_id Ar index extra_id extra_index flags
159 Remove extra field number
160 .Ar extra_index
161 of type
162 .Ar extra_id
163 from archive entry
164 .Ar index
165 using
166 .Ar flags .
167 .It Cm get_archive_comment
168 Print archive comment.
169 .It Cm get_extra Ar index extra_index flags
170 Print extra field
171 .Ar extra_index
172 for archive entry
173 .Ar index
174 using
175 .Ar flags .
176 .It Cm get_extra_by_id Ar index extra_id extra_index flags
177 Print extra field
178 .Ar extra_index
179 of type
180 .Ar extra_id
181 for archive entry
182 .Ar index
183 using
184 .Ar flags .
185 .It Cm get_file_comment Ar index
186 Get file comment for archive entry
187 .Ar index .
188 .It Cm get_num_entries Ar flags
189 Print number of entries in archive using
190 .Ar flags .
191 .It Cm name_locate Ar name flags
192 Find entry in archive with the filename
193 .Ar name
194 using
195 .Ar flags
196 and print its index.
197 .It Cm rename Ar index name
198 Rename archive entry
199 .Ar index
200 to
201 .Ar name .
202 .It Cm replace_file_contents Ar index data
203 Replace file contents for archive entry
204 .Ar index
205 with the string
206 .Ar data .
207 .It Cm set_archive_comment Ar comment
208 Set archive comment to
209 .Ar comment .
210 .It Cm set_extra Ar index extra_id extra_index flags value
211 Set extra field number
212 .Ar extra_index
213 of type
214 .Ar extra_id
215 for archive entry
216 .Ar index
217 using
218 .Ar flags
219 to
220 .Ar value .
221 .It Cm set_file_comment Ar index comment
222 Set file comment for archive entry
223 .Ar index
224 to string
225 .Ar comment .
226 .It Cm set_file_compression Ar index method compression_flags
227 Set file compression method for archive entry
228 .Ar index
229 to
230 .Ar method
231 using
232 .Ar compression_flags .
233 .Em Note :
234 Currently,
235 .Ar compression_flags
236 are ignored.
237 .It Cm set_file_encryption Ar index method password
238 Set file encryption method for archive entry
239 .Ar index
240 to
241 .Ar method
242 with password
243 .Ar password .
244 .It Cm set_file_mtime Ar index timestamp
245 Set file modification time for archive entry
246 .Ar index
247 to UNIX mtime
248 .Ar timestamp .
249 .It Cm set_file_mtime_all Ar timestamp
250 Set file modification time for all archive entries to UNIX mtime
251 .Ar timestamp .
252 .It Cm set_password Ar password
253 Set default password for encryption/decryption to
254 .Ar password .
255 .It Cm stat Ar index
256 Print information about archive entry
257 .Ar index .
258 .El
259 .Ss Flags
260 Some commands take flag arguments.
261 Supported flags are:
262 .Bl -tag -width MMM -compact -offset indent
263 .It Ar C
264 .Dv ZIP_FL_NOCASE
265 .It Ar c
266 .Dv ZIP_FL_CENTRAL
267 .It Ar d
268 .Dv ZIP_FL_NODIR
269 .It Ar l
270 .Dv ZIP_FL_LOCAL
271 .It Ar u
272 .Dv ZIP_FL_UNCHANGED
273 .El
274 .Ss Compression Methods
275 Some commands take compression method arguments.
276 Supported methods are:
277 .Bl -bullet -compact -offset indent
278 .It
279 .Dv default
280 .It
281 .Dv deflate
282 .It
283 .Dv store
284 .El
285 .Ss Encryption Methods
286 Some commands take encryption method arguments.
287 Supported methods are:
288 .Bl -bullet -compact -offset indent
289 .It
290 .Dv none
291 .It
292 .Dv AES-128
293 .It
294 .Dv AES-192
295 .It
296 .Dv AES-256
297 .El
298 .Sh EXIT STATUS
299 .Ex -std
300 .Sh EXAMPLES
301 Add a file called
302 .Pa teststring.txt
303 to the zip archive
304 .Pa testbuffer.zip
305 with data
306 .Dq This is a test.\en
307 where
308 .Dq \en
309 is replaced with a newline character:
310 .Bd -literal -offset indent
311 ziptool testbuffer.zip add teststring.txt \\"This is a test.\en\\"
312 .Ed
313 .Pp
314 Delete the first file from the zip archive
315 .Pa testfile.zip :
316 .Bd -literal -offset indent
317 ziptool testfile.zip delete 0
318 .Ed
319 .Sh SEE ALSO
320 .Xr zipcmp 1 ,
321 .Xr zipmerge 1 ,
322 .Xr libzip 3
323 .Sh HISTORY
324 .Nm
325 was added in libzip 1.1.
326 .Sh AUTHORS
327 .An -nosplit
328 .An Dieter Baron Aq Mt dillo@nih.at
329 and
330 .An Thomas Klausner Aq Mt tk@giga.or.at