CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
Path: blob/master/ext/libzip/zip_file_add.c
Views: 1401
/*1zip_file_add.c -- add file via callback function2Copyright (C) 1999-2019 Dieter Baron and Thomas Klausner34This file is part of libzip, a library to manipulate ZIP archives.5The authors can be contacted at <[email protected]>67Redistribution and use in source and binary forms, with or without8modification, are permitted provided that the following conditions9are met:101. Redistributions of source code must retain the above copyright11notice, this list of conditions and the following disclaimer.122. Redistributions in binary form must reproduce the above copyright13notice, this list of conditions and the following disclaimer in14the documentation and/or other materials provided with the15distribution.163. The names of the authors may not be used to endorse or promote17products derived from this software without specific prior18written permission.1920THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS21OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED22WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE23ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY24DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL25DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE26GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS27INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER28IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR29OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN30IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.31*/323334#include "zipint.h"3536/*37NOTE: Return type is signed so we can return -1 on error.38The index can not be larger than ZIP_INT64_MAX since the size39of the central directory cannot be larger than40ZIP_UINT64_MAX, and each entry is larger than 2 bytes.41*/4243ZIP_EXTERN zip_int64_t44zip_file_add(zip_t *za, const char *name, zip_source_t *source, zip_flags_t flags) {45if (name == NULL || source == NULL) {46zip_error_set(&za->error, ZIP_ER_INVAL, 0);47return -1;48}4950return _zip_file_replace(za, ZIP_UINT64_MAX, name, source, flags);51}525354