cvs: php-src /ext/zip config.m4 config.w32 php_zip.c /ext/zip/lib zip.h zip_add_dir.c zip_error.c zip_error_clear.c zip_file_error_clear.c
zip_source_buffer.c zip_source_filep.c zip_stat_index.c zip_stat_init.c

From: Date: Wed, 01 Nov 2006 00:53:32 +0000
Subject: cvs: php-src /ext/zip config.m4 config.w32 php_zip.c /ext/zip/lib zip.h zip_add_dir.c zip_error.c zip_error_clear.c zip_file_error_clear.c
zip_source_buffer.c zip_source_filep.c zip_stat_index.c zip_stat_init.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-41274@lists.php.net to get a copy of this message
pajoye Wed Nov 1 00:53:32 2006 UTC Added files: /php-src/ext/zip/lib zip_add_dir.c zip_error_clear.c zip_file_error_clear.c zip_stat_init.c Modified files: /php-src/ext/zip config.m4 config.w32 php_zip.c /php-src/ext/zip/lib zip.h zip_error.c zip_source_buffer.c zip_source_filep.c zip_stat_index.c Log: - fix stat when used with freshly added entries - add zip_clear_error, zip_file_clear_error and zip_stat_init in libzip - add addEmptyDir(name) method, creates an empty directory

http://cvs.php.net/viewvc.cgi/php-src/ext/zip/config.m4?r1=1.8&r2=1.9&diff_format=u Index: php-src/ext/zip/config.m4 diff -u php-src/ext/zip/config.m4:1.8 php-src/ext/zip/config.m4:1.9 --- php-src/ext/zip/config.m4:1.8 Mon Jul 24 16:58:58 2006 +++ php-src/ext/zip/config.m4 Wed Nov 1 00:53:32 2006 @@ -1,5 +1,5 @@ dnl -dnl $Id: config.m4,v 1.8 2006/07/24 16:58:58 pajoye Exp $ +dnl $Id: config.m4,v 1.9 2006/11/01 00:53:32 pajoye Exp $ dnl PHP_ARG_ENABLE(zip, for zip archive read/writesupport, @@ -59,7 +59,8 @@ lib/zip_entry_new.c lib/zip_err_str.c lib/zip_fopen_index.c \ lib/zip_new.c lib/zip_source_file.c lib/zip_stat_index.c lib/zip_get_archive_comment.c \ lib/zip_get_file_comment.c lib/zip_set_archive_comment.c lib/zip_set_file_comment.c \ - lib/zip_unchange_archive.c lib/zip_memdup.c" + lib/zip_unchange_archive.c lib/zip_memdup.c lib/zip_stat_init.c lib/zip_add_dir.c \ + lib/zip_error_clear.c lib/zip_file_error_clear.c" AC_DEFINE(HAVE_ZIP,1,[ ]) PHP_NEW_EXTENSION(zip, php_zip.c zip_stream.c $PHP_ZIP_SOURCES, $ext_shared) http://cvs.php.net/viewvc.cgi/php-src/ext/zip/config.w32?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/zip/config.w32 diff -u php-src/ext/zip/config.w32:1.1 php-src/ext/zip/config.w32:1.2 --- php-src/ext/zip/config.w32:1.1 Mon Jul 24 16:58:58 2006 +++ php-src/ext/zip/config.w32 Wed Nov 1 00:53:32 2006 @@ -1,4 +1,4 @@ -// $Id: config.w32,v 1.1 2006/07/24 16:58:58 pajoye Exp $ +// $Id: config.w32,v 1.2 2006/11/01 00:53:32 pajoye Exp $ // vim:ft=javascript ARG_ENABLE("zip", "ZIP support", "no"); @@ -26,7 +26,8 @@ zip_new.c zip_source_file.c zip_stat_index.c \ zip_get_archive_comment.c zip_get_file_comment.c \ zip_set_archive_comment.c zip_set_file_comment.c \ - zip_unchange_archive.c zip_memdup.c", "zip"); + zip_unchange_archive.c zip_memdup.c zip_stat_init.c \ + zip_add_dir.c zip_file_error_clear.c zip_error_clear.c", "zip"); AC_DEFINE('HAVE_ZLIB', 1); AC_DEFINE('HAVE_ZIP', 1); http://cvs.php.net/viewvc.cgi/php-src/ext/zip/php_zip.c?r1=1.26&r2=1.27&diff_format=u Index: php-src/ext/zip/php_zip.c diff -u php-src/ext/zip/php_zip.c:1.26 php-src/ext/zip/php_zip.c:1.27 --- php-src/ext/zip/php_zip.c:1.26 Tue Oct 31 23:25:41 2006 +++ php-src/ext/zip/php_zip.c Wed Nov 1 00:53:32 2006 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_zip.c,v 1.26 2006/10/31 23:25:41 pajoye Exp $ */ +/* $Id: php_zip.c,v 1.27 2006/11/01 00:53:32 pajoye Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -935,6 +935,35 @@ } /* }}} */ +/* {{{ proto bool createEmptyDir(string dirname) U +Returns the index of the entry named filename in the archive */ +ZIPARCHIVE_METHOD(addEmptyDir) +{ + struct zip *intern; + zval *this = getThis(); + char *dirname; + int dirname_len; + + if (!this) { + RETURN_FALSE; + } + + ZIP_FROM_OBJECT(intern, this); + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s&", + &dirname, &dirname_len, UG(ascii_conv)) == FAILURE) { + return; + } + if (dirname_len<1) { + RETURN_FALSE; + } + + if (zip_add_dir(intern, (const char *)dirname) < 0) { + RETURN_FALSE; + } +} +/* }}} */ + /* {{{ proto bool addFile(string filepath[, string entryname[, int start [, int length]]]) U Add a file in a Zip archive using its path and the name to use. */ ZIPARCHIVE_METHOD(addFile) @@ -1904,6 +1933,7 @@ static zend_function_entry zip_class_functions[] = { ZIPARCHIVE_ME(open, NULL, ZEND_ACC_PUBLIC) ZIPARCHIVE_ME(close, NULL, ZEND_ACC_PUBLIC) + ZIPARCHIVE_ME(addEmptyDir, NULL, ZEND_ACC_PUBLIC) ZIPARCHIVE_ME(addFromString, NULL, ZEND_ACC_PUBLIC) ZIPARCHIVE_ME(addFile, NULL, ZEND_ACC_PUBLIC) ZIPARCHIVE_ME(renameIndex, NULL, ZEND_ACC_PUBLIC) @@ -2033,7 +2063,7 @@ php_info_print_table_start(); php_info_print_table_row(2, "Zip", "enabled"); - php_info_print_table_row(2, "Extension Version","$Id: php_zip.c,v 1.26 2006/10/31 23:25:41 pajoye Exp $"); + php_info_print_table_row(2, "Extension Version","$Id: php_zip.c,v 1.27 2006/11/01 00:53:32 pajoye Exp $"); php_info_print_table_row(2, "Zip version", "2.0.0"); php_info_print_table_row(2, "Libzip version", "0.7.1"); http://cvs.php.net/viewvc.cgi/php-src/ext/zip/lib/zip.h?r1=1.2&r2=1.3&diff_format=u Index: php-src/ext/zip/lib/zip.h diff -u php-src/ext/zip/lib/zip.h:1.2 php-src/ext/zip/lib/zip.h:1.3 --- php-src/ext/zip/lib/zip.h:1.2 Sun Aug 13 20:16:48 2006 +++ php-src/ext/zip/lib/zip.h Wed Nov 1 00:53:32 2006 @@ -163,12 +163,15 @@ int zip_add(struct zip *, const char *, struct zip_source *); +int zip_add_dir(struct zip *, const char *); int zip_close(struct zip *); int zip_delete(struct zip *, int); +void zip_error_clear(struct zip *); void zip_error_get(struct zip *, int *, int *); int zip_error_get_sys_type(int); int zip_error_to_str(char *, size_t, int, int); int zip_fclose(struct zip_file *); +void zip_file_error_clear(struct zip_file *); void zip_file_error_get(struct zip_file *, int *, int *); const char *zip_file_strerror(struct zip_file *); struct zip_file *zip_fopen(struct zip *, const char *, int); @@ -194,6 +197,7 @@ off_t, off_t); int zip_stat(struct zip *, const char *, int, struct zip_stat *); int zip_stat_index(struct zip *, int, int, struct zip_stat *); +void zip_stat_init(struct zip_stat *); const char *zip_strerror(struct zip *); int zip_unchange(struct zip *, int); int zip_unchange_all(struct zip *); http://cvs.php.net/viewvc.cgi/php-src/ext/zip/lib/zip_error.c?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/zip/lib/zip_error.c diff -u php-src/ext/zip/lib/zip_error.c:1.1 php-src/ext/zip/lib/zip_error.c:1.2 --- php-src/ext/zip/lib/zip_error.c:1.1 Mon Jul 24 16:58:58 2006 +++ php-src/ext/zip/lib/zip_error.c Wed Nov 1 00:53:32 2006 @@ -2,7 +2,7 @@ $NiH: zip_error.c,v 1.7 2005/06/09 19:57:09 dillo Exp $ zip_error.c -- struct zip_error helper functions - Copyright (C) 1999, 2003, 2004, 2005 Dieter Baron and Thomas Klausner + Copyright (C) 1999-2006 Dieter Baron and Thomas Klausner This file is part of libzip, a library to manipulate ZIP archives. The authors can be contacted at <nih@giga.or.at> @@ -43,6 +43,15 @@ void +_zip_error_clear(struct zip_error *err) +{ + err->zip_err = ZIP_ER_OK; + err->sys_err = 0; +} + + + +void _zip_error_copy(struct zip_error *dst, struct zip_error *src) { dst->zip_err = src->zip_err; @@ -78,7 +87,7 @@ void _zip_error_init(struct zip_error *err) { - err->zip_err = 0; + err->zip_err = ZIP_ER_OK; err->sys_err = 0; err->str = NULL; } http://cvs.php.net/viewvc.cgi/php-src/ext/zip/lib/zip_source_buffer.c?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/zip/lib/zip_source_buffer.c diff -u php-src/ext/zip/lib/zip_source_buffer.c:1.1 php-src/ext/zip/lib/zip_source_buffer.c:1.2 --- php-src/ext/zip/lib/zip_source_buffer.c:1.1 Mon Jul 24 16:58:58 2006 +++ php-src/ext/zip/lib/zip_source_buffer.c Wed Nov 1 00:53:32 2006 @@ -2,7 +2,7 @@ $NiH: zip_source_buffer.c,v 1.8 2006/04/23 14:50:49 wiz Exp $ zip_source_buffer.c -- create zip data source from buffer - Copyright (C) 1999, 2003, 2004, 2005 Dieter Baron and Thomas Klausner + Copyright (C) 1999-2006 Dieter Baron and Thomas Klausner This file is part of libzip, a library to manipulate ZIP archives. The authors can be contacted at <nih@giga.or.at> @@ -125,11 +125,9 @@ st = (struct zip_stat *)data; + zip_stat_init(st); st->mtime = z->mtime; - st->crc = 0; st->size = z->end - z->data; - st->comp_size = -1; - st->comp_method = ZIP_CM_STORE; return sizeof(*st); } http://cvs.php.net/viewvc.cgi/php-src/ext/zip/lib/zip_source_filep.c?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/zip/lib/zip_source_filep.c diff -u php-src/ext/zip/lib/zip_source_filep.c:1.1 php-src/ext/zip/lib/zip_source_filep.c:1.2 --- php-src/ext/zip/lib/zip_source_filep.c:1.1 Mon Jul 24 16:58:58 2006 +++ php-src/ext/zip/lib/zip_source_filep.c Wed Nov 1 00:53:32 2006 @@ -2,7 +2,7 @@ $NiH: zip_source_filep.c,v 1.6 2005/06/09 19:57:10 dillo Exp $ zip_source_filep.c -- create data source from FILE * - Copyright (C) 1999, 2003, 2004, 2005 Dieter Baron and Thomas Klausner + Copyright (C) 1999-2006 Dieter Baron and Thomas Klausner This file is part of libzip, a library to manipulate ZIP archives. The authors can be contacted at <nih@giga.or.at> @@ -138,24 +138,20 @@ if (len < sizeof(*st)) return -1; - st = (struct zip_stat *)data; - if (fstat(fileno(z->f), &fst) != 0) { z->e[0] = ZIP_ER_READ; /* best match */ z->e[1] = errno; return -1; } + st = (struct zip_stat *)data; + + zip_stat_init(st); st->mtime = fst.st_mtime; - st->crc = 0; if (z->len != -1) st->size = z->len; else if ((fst.st_mode&S_IFMT) == S_IFREG) st->size = fst.st_size; - else - st->size = -1; - st->comp_size = -1; - st->comp_method = ZIP_CM_STORE; return sizeof(*st); } http://cvs.php.net/viewvc.cgi/php-src/ext/zip/lib/zip_stat_index.c?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/zip/lib/zip_stat_index.c diff -u php-src/ext/zip/lib/zip_stat_index.c:1.1 php-src/ext/zip/lib/zip_stat_index.c:1.2 --- php-src/ext/zip/lib/zip_stat_index.c:1.1 Mon Jul 24 16:58:58 2006 +++ php-src/ext/zip/lib/zip_stat_index.c Wed Nov 1 00:53:32 2006 @@ -68,7 +68,6 @@ return -1; } - st->index = index; st->crc = za->cdir->entry[index].crc; st->size = za->cdir->entry[index].uncomp_size; st->mtime = za->cdir->entry[index].last_mod; @@ -87,6 +86,7 @@ /* st->bitflags = za->cdir->entry[index].bitflags; */ } + st->index = index; st->name = name; return 0; http://cvs.php.net/viewvc.cgi/php-src/ext/zip/lib/zip_add_dir.c?view=markup&rev=1.1 Index: php-src/ext/zip/lib/zip_add_dir.c +++ php-src/ext/zip/lib/zip_add_dir.c /* $NiH: zip_add_dir.c,v 1.1 2006/10/03 12:23:13 dillo Exp $ zip_add_dir.c -- add directory Copyright (C) 1999-2006 Dieter Baron and Thomas Klausner This file is part of libzip, a library to manipulate ZIP archives. The authors can be contacted at <nih@giga.or.at> Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The names of the authors may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include <stdlib.h> #include <string.h> #include "zip.h" #include "zipint.h" int zip_add_dir(struct zip *za, const char *name) { int len, ret; char *s; struct zip_source *source; if (name == NULL) { _zip_error_set(&za->error, ZIP_ER_INVAL, 0); return -1; } s = NULL; len = strlen(name); if (name[len-1] != '/') { if ((s=(char *)malloc(len+2)) == NULL) { _zip_error_set(&za->error, ZIP_ER_MEMORY, 0); return -1; } strcpy(s, name); s[len] = '/'; s[len+1] = '\0'; } if ((source=zip_source_buffer(za, NULL, 0, 0)) == NULL) { free(s); return -1; } ret = _zip_replace(za, -1, s ? s : name, source); free(s); if (ret < 0) zip_source_free(source); return ret; } http://cvs.php.net/viewvc.cgi/php-src/ext/zip/lib/zip_error_clear.c?view=markup&rev=1.1 Index: php-src/ext/zip/lib/zip_error_clear.c +++ php-src/ext/zip/lib/zip_error_clear.c /* $NiH: zip_error_clear.c,v 1.1 2006/10/04 15:21:09 dillo Exp $ zip_error_clear.c -- clear zip error Copyright (C) 1999-2006 Dieter Baron and Thomas Klausner This file is part of libzip, a library to manipulate ZIP archives. The authors can be contacted at <nih@giga.or.at> Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The names of the authors may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "zip.h" #include "zipint.h" void zip_error_clear(struct zip *za) { _zip_error_clear(&za->error); } http://cvs.php.net/viewvc.cgi/php-src/ext/zip/lib/zip_file_error_clear.c?view=markup&rev=1.1 Index: php-src/ext/zip/lib/zip_file_error_clear.c +++ php-src/ext/zip/lib/zip_file_error_clear.c /* $NiH: zip_file_error_clear.c,v 1.4 2006/10/04 18:37:54 wiz Exp $ zip_file_error_clear.c -- clear zip file error Copyright (C) 1999-2006 Dieter Baron and Thomas Klausner This file is part of libzip, a library to manipulate ZIP archives. The authors can be contacted at <nih@giga.or.at> Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The names of the authors may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "zip.h" #include "zipint.h" void zip_file_error_clear(struct zip_file *zf) { _zip_error_clear(&zf->error); } http://cvs.php.net/viewvc.cgi/php-src/ext/zip/lib/zip_stat_init.c?view=markup&rev=1.1 Index: php-src/ext/zip/lib/zip_stat_init.c +++ php-src/ext/zip/lib/zip_stat_init.c /* $NiH: zip_stat_init.c,v 1.1 2006/10/31 12:03:04 dillo Exp $ zip_stat_init.c -- initialize struct zip_stat. Copyright (C) 2006 Dieter Baron and Thomas Klausner This file is part of libzip, a library to manipulate ZIP archives. The authors can be contacted at <nih@giga.or.at> Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The names of the authors may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "zipint.h" void zip_stat_init(struct zip_stat *st) { st->name = NULL; st->index = -1; st->crc = 0; st->mtime = (time_t)-1; st->size = -1; st->comp_size = -1; st->comp_method = ZIP_CM_STORE; st->encryption_method = ZIP_EM_NONE; }
« previous php.cvs (#41274) next »