Imported Upstream version 1.4.0
[platform/upstream/libzip.git] / man / zip_file_rename.mdoc
1 .\" zip_file_rename.mdoc -- rename file in zip archive
2 .\" Copyright (C) 2003-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 ZIP_FILE_RENAME 3
34 .Os
35 .Sh NAME
36 .Nm zip_file_rename
37 .Nd rename file in zip archive
38 .Sh LIBRARY
39 libzip (-lzip)
40 .Sh SYNOPSIS
41 .In zip.h
42 .Ft int
43 .Fn zip_file_rename "zip_t *archive" "zip_uint64_t index" "const char *name" "zip_flags_t flags"
44 .Sh DESCRIPTION
45 The file at position
46 .Ar index
47 in the zip archive
48 .Ar archive
49 is renamed to
50 .Ar name .
51 The
52 .Ar flags
53 argument can be any of:
54 .Bl -tag -width XZIPXFLXENCXSTRICTXX
55 .It Dv ZIP_FL_ENC_GUESS
56 Guess encoding of
57 .Ar name
58 (default).
59 .It Dv ZIP_FL_ENC_UTF_8
60 Interpret
61 .Ar name
62 as UTF-8.
63 .It Dv ZIP_FL_ENC_CP437
64 Interpret
65 .Ar name
66 as code page 437 (CP-437).
67 .El
68 .Sh RETURN VALUES
69 Upon successful completion 0 is returned.
70 Otherwise, \-1 is returned and the error code in
71 .Ar archive
72 is set to indicate the error.
73 .Sh ERRORS
74 .Fn zip_rename
75 fails if:
76 .Bl -tag -width Er
77 .It Bq Er ZIP_ER_DELETED
78 The file to be renamed has been deleted from the archive.
79 .It Bq Er ZIP_ER_EXISTS
80 There is already a file called
81 .Ar name
82 in the archive.
83 .It Bq Er ZIP_ER_INVAL
84 .Ar index
85 is not a valid file index in
86 .Ar archive ,
87 .Ar name is
88 .Dv NULL ,
89 the empty string, or not a valid UTF-8 encoded string.
90 Also a file cannot be renamed to a directory or vice versa.
91 Directories are denoted by a trailing slash.
92 .El
93 .Sh SEE ALSO
94 .Xr libzip 3 ,
95 .Xr zip_unchange 3
96 .Sh HISTORY
97 .Fn zip_file_rename
98 was added in libzip 0.11.
99 .Sh AUTHORS
100 .An -nosplit
101 .An Dieter Baron Aq Mt dillo@nih.at
102 and
103 .An Thomas Klausner Aq Mt tk@giga.or.at