Imported Upstream version 1.9.0
[platform/upstream/libzip.git] / man / ziptool.man
1 .\" Automatically generated from an mdoc input file.  Do not edit.
2 .\" ziptool.mdoc -- modify zip archives in multiple ways
3 .\" Copyright (C) 2016-2022 Dieter Baron and Thomas Klausner
4 .\"
5 .\" This file is part of libzip, a library to manipulate ZIP archives.
6 .\" The authors can be contacted at <libzip@nih.at>
7 .\"
8 .\" Redistribution and use in source and binary forms, with or without
9 .\" modification, are permitted provided that the following conditions
10 .\" are met:
11 .\" 1. Redistributions of source code must retain the above copyright
12 .\"    notice, this list of conditions and the following disclaimer.
13 .\" 2. Redistributions in binary form must reproduce the above copyright
14 .\"    notice, this list of conditions and the following disclaimer in
15 .\"    the documentation and/or other materials provided with the
16 .\"    distribution.
17 .\" 3. The names of the authors may not be used to endorse or promote
18 .\"    products derived from this software without specific prior
19 .\"    written permission.
20 .\"
21 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
22 .\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23 .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
25 .\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
27 .\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
29 .\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
30 .\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
31 .\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 .\"
33 .TH "ZIPTOOL" "1" "March 15, 2022" "NiH" "General Commands Manual"
34 .nh
35 .if n .ad l
36 .SH "NAME"
37 \fBziptool\fR
38 \- modify zip archives
39 .SH "SYNOPSIS"
40 .HP 8n
41 \fBziptool\fR
42 [\fB\-ceghnrst\fR]
43 [\fB\-l\fR\ \fIlength\fR]
44 [\fB\-o\fR\ \fIoffset\fR]
45 \fIzip-archive\fR
46 \fBcommand\fR\ [\fIcommand-args\ ...\fR]
47 [\fBcommand\fR\ [\fIcommand-args\ ...\fR]\ ...]
48 .SH "DESCRIPTION"
49 \fBziptool\fR
50 modifies the zip archive
51 \fIzip-archive\fR
52 according to the
53 \fIcommands\fR
54 given.
55 .PP
56 Supported options:
57 .TP 13n
58 \fB\-c\fR
59 Check zip archive consistency when opening it.
60 .TP 13n
61 \fB\-e\fR
62 Error if archive already exists (only useful with
63 \fB\-n\fR).
64 .TP 13n
65 \fB\-g\fR
66 Guess file name encoding (for
67 \fBstat\fR
68 command).
69 .TP 13n
70 \fB\-h\fR
71 Display help.
72 .TP 13n
73 \fB\-l\fR \fIlength\fR
74 Only read
75 \fIlength\fR
76 bytes of archive.
77 See also
78 \fB\-o\fR.
79 .TP 13n
80 \fB\-n\fR
81 Create archive if it doesn't exist.
82 See also
83 \fB\-e\fR.
84 .TP 13n
85 \fB\-o\fR \fIoffset\fR
86 Start reading input archive from
87 \fIoffset\fR.
88 See also
89 \fB\-l\fR.
90 .TP 13n
91 \fB\-r\fR
92 Print raw file name encoding without translation (for
93 \fBstat\fR
94 command).
95 .TP 13n
96 \fB\-s\fR
97 Follow file name convention strictly (for
98 \fBstat\fR
99 command).
100 .TP 13n
101 \fB\-t\fR
102 Disregard current file contents, if any.
103 \fINote\fR:
104 use this with care, it deletes all existing file contents when
105 you modify the archive.
106 .SS "Commands"
107 For all commands below, the index is zero-based.
108 In other words, the first entry in the zip archive has index 0.
109 .PP
110 Supported commands and arguments are:
111 .TP 12n
112 \fBadd\fR \fIname content\fR
113 Add file called
114 \fIname\fR
115 using the string
116 \fIcontent\fR
117 from the command line as data.
118 .TP 12n
119 \fBadd_dir\fR \fIname\fR
120 Add directory
121 \fIname\fR.
122 .TP 12n
123 \fBadd_file\fR \fIname file_to_add offset len\fR
124 Add file
125 \fIname\fR
126 to archive, using
127 \fIlen\fR
128 bytes from the file
129 \fIfile_to_add\fR
130 as input data, starting at
131 \fIoffset\fR.
132 .TP 12n
133 \fBadd_from_zip\fR \fIname archivename index offset len\fR
134 Add file called
135 \fIname\fR
136 to archive using data from another zip archive
137 \fIarchivename\fR
138 using the entry with index
139 \fIindex\fR
140 and reading
141 \fIlen\fR
142 bytes from
143 \fIoffset\fR.
144 .TP 12n
145 \fBcat\fR \fIindex\fR
146 Output file contents for entry
147 \fIindex\fR
148 to stdout.
149 .TP 12n
150 \fBcount_extra\fR \fIindex flags\fR
151 Print the number of extra fields for archive entry
152 \fIindex\fR
153 using
154 \fIflags\fR.
155 .TP 12n
156 \fBcount_extra_by_id\fR \fIindex extra_id flags\fR
157 Print number of extra fields of type
158 \fIextra_id\fR
159 for archive entry
160 \fIindex\fR
161 using
162 \fIflags\fR.
163 .TP 12n
164 \fBdelete\fR \fIindex\fR
165 Remove entry at
166 \fIindex\fR
167 from zip archive.
168 .TP 12n
169 \fBdelete_extra\fR \fIindex extra_idx flags\fR
170 Remove extra field number
171 \fIextra_idx\fR
172 from archive entry
173 \fIindex\fR
174 using
175 \fIflags\fR.
176 .TP 12n
177 \fBdelete_extra_by_id\fR \fIindex extra_id extra_index flags\fR
178 Remove extra field number
179 \fIextra_index\fR
180 of type
181 \fIextra_id\fR
182 from archive entry
183 \fIindex\fR
184 using
185 \fIflags\fR.
186 .TP 12n
187 \fBget_archive_comment\fR
188 Print archive comment.
189 .TP 12n
190 \fBget_extra\fR \fIindex extra_index flags\fR
191 Print extra field
192 \fIextra_index\fR
193 for archive entry
194 \fIindex\fR
195 using
196 \fIflags\fR.
197 .TP 12n
198 \fBget_extra_by_id\fR \fIindex extra_id extra_index flags\fR
199 Print extra field
200 \fIextra_index\fR
201 of type
202 \fIextra_id\fR
203 for archive entry
204 \fIindex\fR
205 using
206 \fIflags\fR.
207 .TP 12n
208 \fBget_file_comment\fR \fIindex\fR
209 Get file comment for archive entry
210 \fIindex\fR.
211 .TP 12n
212 \fBget_num_entries\fR \fIflags\fR
213 Print number of entries in archive using
214 \fIflags\fR.
215 .TP 12n
216 \fBname_locate\fR \fIname flags\fR
217 Find entry in archive with the filename
218 \fIname\fR
219 using
220 \fIflags\fR
221 and print its index.
222 .TP 12n
223 \fBrename\fR \fIindex name\fR
224 Rename archive entry
225 \fIindex\fR
226 to
227 \fIname\fR.
228 .TP 12n
229 \fBreplace_file_contents\fR \fIindex data\fR
230 Replace file contents for archive entry
231 \fIindex\fR
232 with the string
233 \fIdata\fR.
234 .TP 12n
235 \fBset_archive_comment\fR \fIcomment\fR
236 Set archive comment to
237 \fIcomment\fR.
238 .TP 12n
239 \fBset_extra\fR \fIindex extra_id extra_index flags value\fR
240 Set extra field number
241 \fIextra_index\fR
242 of type
243 \fIextra_id\fR
244 for archive entry
245 \fIindex\fR
246 using
247 \fIflags\fR
248 to
249 \fIvalue\fR.
250 .TP 12n
251 \fBset_file_comment\fR \fIindex comment\fR
252 Set file comment for archive entry
253 \fIindex\fR
254 to string
255 \fIcomment\fR.
256 .TP 12n
257 \fBset_file_compression\fR \fIindex method compression_flags\fR
258 Set file compression method for archive entry
259 \fIindex\fR
260 to
261 \fImethod\fR
262 using
263 \fIcompression_flags\fR.
264 \fINote\fR:
265 Currently,
266 \fIcompression_flags\fR
267 are ignored.
268 .TP 12n
269 \fBset_file_encryption\fR \fIindex method password\fR
270 Set file encryption method for archive entry
271 \fIindex\fR
272 to
273 \fImethod\fR
274 with password
275 \fIpassword\fR.
276 .TP 12n
277 \fBset_file_mtime\fR \fIindex timestamp\fR
278 Set file modification time for archive entry
279 \fIindex\fR
280 to UNIX mtime
281 \fItimestamp\fR.
282 .TP 12n
283 \fBset_file_mtime_all\fR \fItimestamp\fR
284 Set file modification time for all archive entries to UNIX mtime
285 \fItimestamp\fR.
286 .TP 12n
287 \fBset_password\fR \fIpassword\fR
288 Set default password for encryption/decryption to
289 \fIpassword\fR.
290 .TP 12n
291 \fBstat\fR \fIindex\fR
292 Print information about archive entry
293 \fIindex\fR.
294 .SS "Flags"
295 Some commands take flag arguments. Each character in the argument sets the corresponding flag. Use 0 or the empty string for no flags.
296 .PP
297 Supported flags are:
298 .RS 6n
299 .PD 0
300 .TP 5n
301 \fI4\fR
302 \fRZIP_FL_ENC_CP437\fR
303 .TP 5n
304 \fI8\fR
305 \fRZIP_FL_ENC_UTF_8\fR
306 .TP 5n
307 \fIC\fR
308 \fRZIP_FL_NOCASE\fR
309 .TP 5n
310 \fIc\fR
311 \fRZIP_FL_CENTRAL\fR
312 .TP 5n
313 \fId\fR
314 \fRZIP_FL_NODIR\fR
315 .TP 5n
316 \fIl\fR
317 \fRZIP_FL_LOCAL\fR
318 .TP 5n
319 \fIr\fR
320 \fRZIP_FL_ENC_RAW\fR
321 .TP 5n
322 \fIs\fR
323 \fRZIP_FL_ENC_STRICT\fR
324 .TP 5n
325 \fIu\fR
326 \fRZIP_FL_UNCHANGED\fR
327 .RE
328 .PD
329 .SS "Compression Methods"
330 Some commands take compression method arguments.
331 Supported methods are:
332 .RS 6n
333 .PD 0
334 .TP 4n
335 \fB\(bu\fR
336 \fRdefault\fR
337 .TP 4n
338 \fB\(bu\fR
339 \fRdeflate\fR
340 .TP 4n
341 \fB\(bu\fR
342 \fRstore\fR
343 .RE
344 .PD
345 .SS "Encryption Methods"
346 Some commands take encryption method arguments.
347 Supported methods are:
348 .RS 6n
349 .PD 0
350 .TP 4n
351 \fB\(bu\fR
352 \fRnone\fR
353 .TP 4n
354 \fB\(bu\fR
355 \fRAES-128\fR
356 .TP 4n
357 \fB\(bu\fR
358 \fRAES-192\fR
359 .TP 4n
360 \fB\(bu\fR
361 \fRAES-256\fR
362 .RE
363 .PD
364 .SH "EXIT STATUS"
365 .br
366 The \fBziptool\fR utility exits\~0 on success, and\~>0 if an error occurs.
367 .SH "EXAMPLES"
368 Add a file called
369 \fIteststring.txt\fR
370 to the zip archive
371 \fItestbuffer.zip\fR
372 with data
373 \(lqThis is a test.\en\(rq
374 where
375 \(lq\en\(rq
376 is replaced with a newline character:
377 .nf
378 .sp
379 .RS 6n
380 ziptool testbuffer.zip add teststring.txt \\"This is a test.\en\\"
381 .RE
382 .fi
383 .PP
384 Delete the first file from the zip archive
385 \fItestfile.zip\fR:
386 .nf
387 .sp
388 .RS 6n
389 ziptool testfile.zip delete 0
390 .RE
391 .fi
392 .SH "SEE ALSO"
393 zipcmp(1),
394 zipmerge(1),
395 libzip(3)
396 .SH "HISTORY"
397 \fBziptool\fR
398 was added in libzip 1.1.
399 .SH "AUTHORS"
400 Dieter Baron <\fIdillo@nih.at\fR>
401 and
402 Thomas Klausner <\fItk@giga.or.at\fR>