"Fossies" - the Fresh Open Source Software Archive

Member "libzip-1.6.0/man/zip_file_add.mdoc" (24 Jan 2020, 4405 Bytes) of package /linux/misc/libzip-1.6.0.tar.xz:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "zip_file_add.mdoc": 1.5.2_vs_1.6.0.

    1 .\" zip_file_add.mdoc -- add files to zip archive
    2 .\" Copyright (C) 2004-2019 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_ADD 3
   34 .Os
   35 .Sh NAME
   36 .Nm zip_file_add ,
   37 .Nm zip_file_replace
   38 .Nd add file to zip archive or replace file in zip archive
   39 .Sh LIBRARY
   40 libzip (-lzip)
   41 .Sh SYNOPSIS
   42 .In zip.h
   43 .Ft zip_int64_t
   44 .Fn zip_file_add "zip_t *archive" "const char *name" "zip_source_t *source" "zip_flags_t flags"
   45 .Ft int
   46 .Fn zip_file_replace "zip_t *archive" "zip_uint64_t index" "zip_source_t *source" "zip_flags_t flags"
   47 .Sh DESCRIPTION
   48 The function
   49 .Fn zip_file_add
   50 adds a file to a zip archive, while
   51 .Fn zip_file_replace
   52 replaces an existing file in a zip archive.
   53 The argument
   54 .Ar archive
   55 specifies the zip archive to which the file should be added.
   56 .Ar name
   57 is the file's name in the zip archive (for
   58 .Fn zip_file_add ) ,
   59 while
   60 .Ar index
   61 specifies which file should be replaced (for
   62 .Fn zip_file_replace ) .
   63 The
   64 .Ar flags
   65 argument can be any combination of
   66 .Dv ZIP_FL_OVERWRITE
   67 with one of
   68 .Dv ZIP_FL_ENC_* :
   69 .Bl -tag -width XZIPXFLXENCXSTRICTXX
   70 .It Dv ZIP_FL_OVERWRITE
   71 Overwrite any existing file of the same name.
   72 For
   73 .Nm zip_file_add
   74 only.
   75 .It Dv ZIP_FL_ENC_GUESS
   76 Guess encoding of
   77 .Ar name
   78 (default).
   79 .It Dv ZIP_FL_ENC_UTF_8
   80 Interpret
   81 .Ar name
   82 as UTF-8.
   83 .It Dv ZIP_FL_ENC_CP437
   84 Interpret
   85 .Ar name
   86 as code page 437 (CP-437).
   87 .El
   88 The data is obtained from the
   89 .Ar source
   90 argument, see
   91 .Xr zip_source 3 .
   92 .Pp
   93 .Em NOTE :
   94 .Xr zip_source_free 3
   95 should not be called on a
   96 .Ar source
   97 after it was used successfully in a
   98 .Nm zip_file_add
   99 or
  100 .Nm zip_file_replace
  101 call.
  102 .Sh RETURN VALUES
  103 Upon successful completion,
  104 .Fn zip_file_add
  105 returns the index of the new file in the archive, and
  106 .Fn zip_file_replace
  107 returns 0.
  108 Otherwise, \-1 is returned and the error code in
  109 .Ar archive
  110 is set to indicate the error.
  111 .Sh EXAMPLES
  112 .Bd -literal -offset indent
  113 zip_source_t *s;
  114 const char *buf="teststring";
  115 
  116 if ((s=zip_source_buffer(archive, buf, sizeof(buf), 0)) == NULL ||
  117     zip_file_add(archive, name, s, ZIP_FL_ENC_UTF_8) < 0) {
  118     zip_source_free(s);
  119     printf("error adding file: %s\en", zip_strerror(archive));
  120 }
  121 .Ed
  122 .Sh ERRORS
  123 .Fn zip_file_add
  124 and
  125 .Fn zip_file_replace
  126 fail if:
  127 .Bl -tag -width Er
  128 .It Bq Er ZIP_ER_EXISTS
  129 There is already a file called
  130 .Ar name
  131 in the archive.
  132 (Only applies to
  133 .Fn zip_file_add ,
  134 and only if
  135 .Dv ZIP_FL_OVERWRITE
  136 is not provided).
  137 .It Bq Er ZIP_ER_INVAL
  138 .Ar source
  139 or
  140 .Ar name
  141 are
  142 .Dv NULL ,
  143 or
  144 .Ar index
  145 is invalid.
  146 .It Bq Er ZIP_ER_MEMORY
  147 Required memory could not be allocated.
  148 .It Bq Er ZIP_ER_RDONLY
  149 Archive was opened in read-only mode.
  150 .El
  151 .Sh SEE ALSO
  152 .Xr libzip 3 ,
  153 .Xr zip_source 3
  154 .Sh HISTORY
  155 .Fn zip_file_add
  156 and
  157 .Fn zip_file_replace
  158 were added in libzip 0.11.
  159 .Sh AUTHORS
  160 .An -nosplit
  161 .An Dieter Baron Aq Mt dillo@nih.at
  162 and
  163 .An Thomas Klausner Aq Mt tk@giga.or.at