pajoye          Fri Nov  3 16:46:19 2006 UTC

  Added files:                 (Branch: PHP_5_2)
    /php-src/ext/zip/lib        zip_add_dir.c zip_error_clear.c 
                                zip_file_error_clear.c zip_stat_init.c 
    /php-src/ext/zip/tests      oo_addemptydir.phpt oo_extract.phpt 
                                oo_get_comment.phpt oo_getnameindex.phpt 
                                oo_setcomment.phpt oo_stream.phpt 
                                test_with_comment.zip 

  Modified files:              
    /php-src/ext/zip    TODO config.m4 config.w32 php_zip.c 
    /php-src/ext/zip/lib        zip.h zip_error.c zip_get_archive_comment.c 
                                zip_source_buffer.c zip_source_filep.c 
                                zip_stat_index.c zipint.h 
    /php-src/ext/zip/tests      utils.inc zip_entry_open.phpt 
                                zip_entry_read.phpt 
  Log:
  - MFH:
   - fix possible leak in statName and statIndex
   - add addEmptyDir() method
   - add zip_stat_init,zip_clear_error and zip_file_clear_error
   - add tests
   - Fix protos (Hannes)
   - setComment return value on success (Hannes)
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/zip/TODO?r1=1.1.2.1&r2=1.1.2.2&diff_format=u
Index: php-src/ext/zip/TODO
diff -u php-src/ext/zip/TODO:1.1.2.1 php-src/ext/zip/TODO:1.1.2.2
--- php-src/ext/zip/TODO:1.1.2.1        Sun Aug 13 00:52:59 2006
+++ php-src/ext/zip/TODO        Fri Nov  3 16:46:18 2006
@@ -1,4 +1,3 @@
-- fix _zip_replace (add two entries with the same name segfaults)
 - add pattern support to extract or add files
 - stream to add or modify entries
 - crypt support for zip (read and write)
http://cvs.php.net/viewvc.cgi/php-src/ext/zip/config.m4?r1=1.8&r2=1.8.2.1&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.8.2.1
--- php-src/ext/zip/config.m4:1.8       Mon Jul 24 16:58:58 2006
+++ php-src/ext/zip/config.m4   Fri Nov  3 16:46:18 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.8.2.1 2006/11/03 16:46:18 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.1.2.1&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.1.2.1
--- php-src/ext/zip/config.w32:1.1      Mon Jul 24 16:58:58 2006
+++ php-src/ext/zip/config.w32  Fri Nov  3 16:46:18 2006
@@ -1,4 +1,4 @@
-// $Id: config.w32,v 1.1 2006/07/24 16:58:58 pajoye Exp $
+// $Id: config.w32,v 1.1.2.1 2006/11/03 16:46:18 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.1.2.15&r2=1.1.2.16&diff_format=u
Index: php-src/ext/zip/php_zip.c
diff -u php-src/ext/zip/php_zip.c:1.1.2.15 php-src/ext/zip/php_zip.c:1.1.2.16
--- php-src/ext/zip/php_zip.c:1.1.2.15  Sun Sep 24 22:27:57 2006
+++ php-src/ext/zip/php_zip.c   Fri Nov  3 16:46:18 2006
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: php_zip.c,v 1.1.2.15 2006/09/24 22:27:57 pajoye Exp $ */
+/* $Id: php_zip.c,v 1.1.2.16 2006/11/03 16:46:18 pajoye Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -70,7 +70,8 @@
                } \
        } else if (zip_set_file_comment(intern, index, comment, comment_len) < 
0) { \
                RETURN_FALSE; \
-       }
+       } \
+       RETURN_TRUE;
 
 /* }}} */
 
@@ -202,7 +203,7 @@
 #define RETURN_SB(sb) \
        { \
                array_init(return_value); \
-               add_assoc_string(return_value, "name", estrdup((sb)->name), 0); 
\
+               add_assoc_string(return_value, "name", (char *)(sb)->name, 1); \
                add_assoc_long(return_value, "index", (long) (sb)->index); \
                add_assoc_long(return_value, "crc", (long) (sb)->crc); \
                add_assoc_long(return_value, "size", (long) (sb)->size); \
@@ -257,7 +258,6 @@
        return NULL;
 }
 /* }}} */
-
 #endif
 
 /* {{{ zend_function_entry */
@@ -888,7 +888,6 @@
        ze_zip_object *ze_obj = NULL;
 
        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &filename, 
&filename_len, &flags) == FAILURE) {
-               WRONG_PARAM_COUNT;
                return;
        }
 
@@ -924,7 +923,7 @@
 }
 /* }}} */
 
-/* {{{ proto resource close()
+/* {{{ proto bool close()
 close the zip archive */
 ZIPARCHIVE_METHOD(close)
 {
@@ -953,6 +952,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) == 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]]])
 Add a file in a Zip archive using its path and the name to use. */
 ZIPARCHIVE_METHOD(addFile)
@@ -1026,7 +1054,7 @@
 }
 /* }}} */
 
-/* {{{ proto resource addFromString(string name, string content)
+/* {{{ proto bool addFromString(string name, string content)
 Add a file using content and the entry name */
 ZIPARCHIVE_METHOD(addFromString)
 {
@@ -1047,7 +1075,6 @@
 
        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss",
                        &name, &name_len, &buffer, &buffer_len) == FAILURE) {
-               WRONG_PARAM_COUNT;
                return;
        }
 
@@ -1092,7 +1119,7 @@
 }
 /* }}} */
 
-/* {{{ proto resource statName(string filename[, int flags])
+/* {{{ proto array statName(string filename[, int flags])
 Returns the information about a the zip entry filename */
 ZIPARCHIVE_METHOD(statName)
 {
@@ -1111,7 +1138,6 @@
 
        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l",
                        &name, &name_len, &flags) == FAILURE) {
-               WRONG_PARAM_COUNT;
                return;
        }
 
@@ -1139,7 +1165,6 @@
 
        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l|l",
                        &index, &flags) == FAILURE) {
-               WRONG_PARAM_COUNT;
                return;
        }
 
@@ -1150,7 +1175,7 @@
 }
 /* }}} */
 
-/* {{{ proto resource locateName(string filename[, int flags])
+/* {{{ proto int locateName(string filename[, int flags])
 Returns the index of the entry named filename in the archive */
 ZIPARCHIVE_METHOD(locateName)
 {
@@ -1169,7 +1194,6 @@
 
        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l",
                        &name, &name_len, &flags) == FAILURE) {
-               WRONG_PARAM_COUNT;
                return;
        }
        if (name_len<1) {
@@ -1191,7 +1215,7 @@
 }
 /* }}} */
 
-/* {{{ proto resource getNameIndex(int index [, int flags])
+/* {{{ proto string getNameIndex(int index [, int flags])
 Returns the name of the file at position index */
 ZIPARCHIVE_METHOD(getNameIndex)
 {
@@ -1208,7 +1232,6 @@
 
        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l|l",
                        &index, &flags) == FAILURE) {
-               WRONG_PARAM_COUNT;
                return;
        }
 
@@ -1222,7 +1245,7 @@
 }
 /* }}} */
 
-/* {{{ proto resource setArchiveComment(string name, string comment)
+/* {{{ proto bool setArchiveComment(string name, string comment)
 Set or remove (NULL/'') the comment of the archive */
 ZIPARCHIVE_METHOD(setArchiveComment)
 {
@@ -1238,7 +1261,6 @@
        ZIP_FROM_OBJECT(intern, this);
 
        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &comment, 
&comment_len) == FAILURE) {
-               WRONG_PARAM_COUNT;
                return;
        }
        if (zip_set_archive_comment(intern, (const char *)comment, 
(int)comment_len)) {
@@ -1249,7 +1271,7 @@
 }
 /* }}} */
 
-/* {{{ proto resource getArchiveComment()
+/* {{{ proto string getArchiveComment()
 Returns the comment of an entry using its index */
 ZIPARCHIVE_METHOD(getArchiveComment)
 {
@@ -1266,16 +1288,15 @@
        ZIP_FROM_OBJECT(intern, this);
 
        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &flags) == 
FAILURE) {
-               WRONG_PARAM_COUNT;
                return;
        }
 
        comment = zip_get_archive_comment(intern, &comment_len, (int)flags);
-       RETURN_STRINGL((char *)comment, comment_len, 1);
+       RETURN_STRINGL((char *)comment, (long)comment_len, 1);
 }
 /* }}} */
 
-/* {{{ proto resource setCommentName(string name, string comment)
+/* {{{ proto bool setCommentName(string name, string comment)
 Set or remove (NULL/'') the comment of an entry using its Name */
 ZIPARCHIVE_METHOD(setCommentName)
 {
@@ -1283,7 +1304,7 @@
        zval *this = getThis();
        int comment_len, name_len;
        char * comment, *name;
-       struct zip_stat sb;
+       int idx;
 
        if (!this) {
                RETURN_FALSE;
@@ -1293,17 +1314,22 @@
 
        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss",
                        &name, &name_len, &comment, &comment_len) == FAILURE) {
-               WRONG_PARAM_COUNT;
                return;
        }
 
+       if (name_len < 1) {
+               php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Empty string as 
entry name");
+       }
 
-       PHP_ZIP_STAT_PATH(intern, name, name_len, 0, sb);
-       PHP_ZIP_SET_FILE_COMMENT(intern, sb.index, comment, comment_len);
+       idx = zip_name_locate(intern, name, 0);
+       if (idx < 0) {
+               RETURN_FALSE;
+       }
+       PHP_ZIP_SET_FILE_COMMENT(intern, idx, comment, comment_len);
 }
 /* }}} */
 
-/* {{{ proto resource setCommentIndex(int index, string comment)
+/* {{{ proto bool setCommentIndex(int index, string comment)
 Set or remove (NULL/'') the comment of an entry using its index */
 ZIPARCHIVE_METHOD(setCommentIndex)
 {
@@ -1322,7 +1348,6 @@
 
        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ls",
                        &index, &comment, &comment_len) == FAILURE) {
-               WRONG_PARAM_COUNT;
                return;
        }
 
@@ -1331,18 +1356,17 @@
 }
 /* }}} */
 
-/* {{{ proto resource getCommentName(string name)
+/* {{{ proto string getCommentName(string name)
 Returns the comment of an entry using its name */
 ZIPARCHIVE_METHOD(getCommentName)
 {
        struct zip *intern;
        zval *this = getThis();
-       int name_len;
+       int name_len, idx;
        long flags = 0;
        int comment_len = 0;
        const char * comment;
        char *name;
-       struct zip_stat sb;
 
        if (!this) {
                RETURN_FALSE;
@@ -1351,18 +1375,25 @@
        ZIP_FROM_OBJECT(intern, this);
 
        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l",
-                       &name, &name_len, &flags) == FAILURE) {
-               WRONG_PARAM_COUNT;
+                       &name, &name_len, &flags) == FAILURE) {;
                return;
        }
+       if (name_len < 1) {
+               php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Empty string as 
entry name");
+               RETURN_FALSE;
+       }
 
-       PHP_ZIP_STAT_PATH(intern, name, name_len, 0, sb);
-       comment = zip_get_file_comment(intern, sb.index, &comment_len, 
(int)flags);
-       RETURN_STRINGL((char *)comment, comment_len, 1);
+       idx = zip_name_locate(intern, name, 0);
+       if (idx < 0) {
+               RETURN_FALSE;
+       }
+
+       comment = zip_get_file_comment(intern, idx, &comment_len, (int)flags);
+       RETURN_STRINGL((char *)comment, (long)comment_len, 1);
 }
 /* }}} */
 
-/* {{{ proto resource getCommentIndex(int index)
+/* {{{ proto string getCommentIndex(int index)
 Returns the comment of an entry using its index */
 ZIPARCHIVE_METHOD(getCommentIndex)
 {
@@ -1381,17 +1412,16 @@
 
        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l|l",
                                &index, &flags) == FAILURE) {
-               WRONG_PARAM_COUNT;
                return;
        }
 
        PHP_ZIP_STAT_INDEX(intern, index, 0, sb);
        comment = zip_get_file_comment(intern, index, &comment_len, (int)flags);
-       RETURN_STRINGL((char *)comment, comment_len, 1);
+       RETURN_STRINGL((char *)comment, (long)comment_len, 1);
 }
 /* }}} */
 
-/* {{{ proto resource deleteIndex(int index)
+/* {{{ proto bool deleteIndex(int index)
 Delete a file using its index */
 ZIPARCHIVE_METHOD(deleteIndex)
 {
@@ -1406,7 +1436,6 @@
        ZIP_FROM_OBJECT(intern, this);
 
        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &index) == 
FAILURE) {
-               WRONG_PARAM_COUNT;
                return;
        }
 
@@ -1422,7 +1451,7 @@
 }
 /* }}} */
 
-/* {{{ proto resource deleteName(string name)
+/* {{{ proto bool deleteName(string name)
 Delete a file using its index */
 ZIPARCHIVE_METHOD(deleteName)
 {
@@ -1439,7 +1468,6 @@
        ZIP_FROM_OBJECT(intern, this);
 
        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, 
&name_len) == FAILURE) {
-               WRONG_PARAM_COUNT;
                return;
        }
        if (name_len < 1) {
@@ -1454,7 +1482,7 @@
 }
 /* }}} */
 
-/* {{{ proto resource renameIndex(int index, string new_name)
+/* {{{ proto bool renameIndex(int index, string new_name)
 Rename an entry selected by its index to new_name */
 ZIPARCHIVE_METHOD(renameIndex)
 {
@@ -1472,7 +1500,6 @@
        ZIP_FROM_OBJECT(intern, this);
 
        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ls", &index, 
&new_name, &new_name_len) == FAILURE) {
-               WRONG_PARAM_COUNT;
                return;
        }
 
@@ -1491,7 +1518,7 @@
 }
 /* }}} */
 
-/* {{{ proto resource renameName(string name, string new_name)
+/* {{{ proto bool renameName(string name, string new_name)
 Rename an entry selected by its name to new_name */
 ZIPARCHIVE_METHOD(renameName)
 {
@@ -1508,7 +1535,6 @@
        ZIP_FROM_OBJECT(intern, this);
 
        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &name, 
&name_len, &new_name, &new_name_len) == FAILURE) {
-               WRONG_PARAM_COUNT;
                return;
        }
 
@@ -1526,7 +1552,7 @@
 }
 /* }}} */
 
-/* {{{ proto resource unchangeIndex(int index)
+/* {{{ proto bool unchangeIndex(int index)
 Changes to the file at position index are reverted */
 ZIPARCHIVE_METHOD(unchangeIndex)
 {
@@ -1541,7 +1567,6 @@
        ZIP_FROM_OBJECT(intern, this);
 
        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &index) == 
FAILURE) {
-               WRONG_PARAM_COUNT;
                return;
        }
 
@@ -1557,7 +1582,7 @@
 }
 /* }}} */
 
-/* {{{ proto resource unchangeName(string name)
+/* {{{ proto bool unchangeName(string name)
 Changes to the file named 'name' are reverted */
 ZIPARCHIVE_METHOD(unchangeName)
 {
@@ -1574,7 +1599,6 @@
        ZIP_FROM_OBJECT(intern, this);
 
        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, 
&name_len) == FAILURE) {
-               WRONG_PARAM_COUNT;
                return;
        }
 
@@ -1592,7 +1616,7 @@
 }
 /* }}} */
 
-/* {{{ proto resource unchangeAll()
+/* {{{ proto bool unchangeAll()
 All changes to files and global information in archive are reverted */
 ZIPARCHIVE_METHOD(unchangeAll)
 {
@@ -1613,7 +1637,7 @@
 }
 /* }}} */
 
-/* {{{ proto resource unchangeAll()
+/* {{{ proto bool unchangeAll()
 Revert all global changes to the archive archive.  For now, this only reverts 
archive comment changes. */
 ZIPARCHIVE_METHOD(unchangeArchive)
 {
@@ -1634,7 +1658,7 @@
 }
 /* }}} */
 
-/* {{{ array resource extractTo(string pathto[, mixed files])
+/* {{{ array bool extractTo(string pathto[, mixed files])
 Extract one or more file from a zip archive */
 /* TODO:
  * - allow index or array of indeces
@@ -1661,7 +1685,6 @@
        }
 
        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|z", &pathto, 
&pathto_len, &zval_files) == FAILURE) {
-               WRONG_PARAM_COUNT;
                return;
        }
 
@@ -1757,13 +1780,11 @@
 
        if (type == 1) {
                if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|ll", 
&filename, &filename_len, &len, &flags) == FAILURE) {
-                       WRONG_PARAM_COUNT;
                        return;
                }
                PHP_ZIP_STAT_PATH(intern, filename, filename_len, flags, sb);
        } else {
                if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l|ll", 
&index, &len, &flags) == FAILURE) {
-                       WRONG_PARAM_COUNT;
                        return;
                }
                PHP_ZIP_STAT_INDEX(intern, index, 0, sb);
@@ -1798,7 +1819,7 @@
 }
 /* }}} */
 
-/* {{{ proto resource getFromName(string entryname[, int len [, int flags]])
+/* {{{ proto string getFromName(string entryname[, int len [, int flags]])
 get the contents of an entry using its name */
 ZIPARCHIVE_METHOD(getFromName)
 {
@@ -1806,7 +1827,7 @@
 }
 /* }}} */
 
-/* {{{ proto resource getFromIndex(string entryname[, int len [, int flags]])
+/* {{{ proto string getFromIndex(string entryname[, int len [, int flags]])
 get the contents of an entry using its index */
 ZIPARCHIVE_METHOD(getFromIndex)
 {
@@ -1834,7 +1855,6 @@
        ZIP_FROM_OBJECT(intern, this);
 
        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &filename, 
&filename_len) == FAILURE) {
-               WRONG_PARAM_COUNT;
                return;
        }
 
@@ -1855,6 +1875,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)
@@ -1984,7 +2005,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.1.2.15 2006/09/24 22:27:57 pajoye Exp $");
+       php_info_print_table_row(2, "Extension Version","$Id: php_zip.c,v 
1.1.2.16 2006/11/03 16:46:18 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.1.2.1&r2=1.1.2.2&diff_format=u
Index: php-src/ext/zip/lib/zip.h
diff -u php-src/ext/zip/lib/zip.h:1.1.2.1 php-src/ext/zip/lib/zip.h:1.1.2.2
--- php-src/ext/zip/lib/zip.h:1.1.2.1   Sun Aug 13 21:09:59 2006
+++ php-src/ext/zip/lib/zip.h   Fri Nov  3 16:46:19 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.1.2.1&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.1.2.1
--- 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     Fri Nov  3 16:46:19 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 <[EMAIL PROTECTED]>
@@ -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_get_archive_comment.c?r1=1.1.2.1&r2=1.1.2.2&diff_format=u
Index: php-src/ext/zip/lib/zip_get_archive_comment.c
diff -u php-src/ext/zip/lib/zip_get_archive_comment.c:1.1.2.1 
php-src/ext/zip/lib/zip_get_archive_comment.c:1.1.2.2
--- php-src/ext/zip/lib/zip_get_archive_comment.c:1.1.2.1       Mon Sep 25 
09:00:16 2006
+++ php-src/ext/zip/lib/zip_get_archive_comment.c       Fri Nov  3 16:46:19 2006
@@ -47,7 +47,7 @@
        || (za->ch_comment_len == -1)) {
                if (za->cdir) {
                        if (lenp != NULL)
-                           *lenp = za->cdir->comment_len;
+                               *lenp = za->cdir->comment_len;
                        return za->cdir->comment;
                }
     }
http://cvs.php.net/viewvc.cgi/php-src/ext/zip/lib/zip_source_buffer.c?r1=1.1&r2=1.1.2.1&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.1.2.1
--- 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     Fri Nov  3 16:46:19 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 <[EMAIL PROTECTED]>
@@ -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.1.2.1&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.1.2.1
--- 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      Fri Nov  3 16:46:19 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 <[EMAIL PROTECTED]>
@@ -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.1.2.1&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.1.2.1
--- 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        Fri Nov  3 16:46:19 2006
@@ -67,8 +67,7 @@
            _zip_error_set(&za->error, ZIP_ER_INVAL, 0);
            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/zipint.h?r1=1.1&r2=1.1.2.1&diff_format=u
Index: php-src/ext/zip/lib/zipint.h
diff -u php-src/ext/zip/lib/zipint.h:1.1 php-src/ext/zip/lib/zipint.h:1.1.2.1
--- php-src/ext/zip/lib/zipint.h:1.1    Mon Jul 24 16:58:58 2006
+++ php-src/ext/zip/lib/zipint.h        Fri Nov  3 16:46:19 2006
@@ -199,6 +199,7 @@
 void _zip_entry_init(struct zip *, int);
 struct zip_entry *_zip_entry_new(struct zip *);
 
+void _zip_error_clear(struct zip_error *);
 void _zip_error_copy(struct zip_error *, struct zip_error *);
 void _zip_error_fini(struct zip_error *);
 void _zip_error_get(struct zip_error *, int *, int *);
http://cvs.php.net/viewvc.cgi/php-src/ext/zip/tests/utils.inc?r1=1.1.2.2&r2=1.1.2.3&diff_format=u
Index: php-src/ext/zip/tests/utils.inc
diff -u php-src/ext/zip/tests/utils.inc:1.1.2.2 
php-src/ext/zip/tests/utils.inc:1.1.2.3
--- php-src/ext/zip/tests/utils.inc:1.1.2.2     Mon Oct  2 14:17:47 2006
+++ php-src/ext/zip/tests/utils.inc     Fri Nov  3 16:46:19 2006
@@ -1,8 +1,24 @@
 <?php
-/* $Id: utils.inc,v 1.1.2.2 2006/10/02 14:17:47 bjori Exp $ */
+/* $Id: utils.inc,v 1.1.2.3 2006/11/03 16:46:19 pajoye Exp $ */
 function dump_entries_name($z) {
        for($i=0; $i<$z->numFiles; $i++) {
            $sb = $z->statIndex($i);
            echo $i . ' ' . $sb['name'] . "\n";
        }
 }
+/* recursively remove a directoryy */
+function rmdir_rf($dir) {
+       if ($handle = opendir($dir)) {
+               while (false !== ($item = readdir($handle))) {
+                       if ($item != "." && $item != "..") {
+                               if (is_dir($dir . '/' . $item)) {
+                                       rmdir_rf($dir . '/' . $item);
+                               } else {
+                                       unlink($dir . '/' . $item);
+                               }
+                       }
+               }
+               closedir($handle);
+               rmdir($dir);
+       }
+}
http://cvs.php.net/viewvc.cgi/php-src/ext/zip/tests/zip_entry_open.phpt?r1=1.1&r2=1.1.2.1&diff_format=u
Index: php-src/ext/zip/tests/zip_entry_open.phpt
diff -u php-src/ext/zip/tests/zip_entry_open.phpt:1.1 
php-src/ext/zip/tests/zip_entry_open.phpt:1.1.2.1
--- php-src/ext/zip/tests/zip_entry_open.phpt:1.1       Mon Jul 24 16:58:58 2006
+++ php-src/ext/zip/tests/zip_entry_open.phpt   Fri Nov  3 16:46:19 2006
@@ -2,7 +2,7 @@
 zip_entry_open() function
 --SKIPIF--
 <?php
-/* $Id: zip_entry_open.phpt,v 1.1 2006/07/24 16:58:58 pajoye Exp $ */
+/* $Id: zip_entry_open.phpt,v 1.1.2.1 2006/11/03 16:46:19 pajoye Exp $ */
 if(!extension_loaded('zip')) die('skip');
 ?>
 --FILE--
@@ -10,6 +10,7 @@
 $zip    = zip_open(dirname(__FILE__)."/test_procedural.zip");
 $entry  = zip_read($zip);
 echo zip_entry_open($zip, $entry, "r") ? "OK" : "Failure";
+zip_entry_close($entry);
 zip_close($zip);
 
 ?>
http://cvs.php.net/viewvc.cgi/php-src/ext/zip/tests/zip_entry_read.phpt?r1=1.1&r2=1.1.2.1&diff_format=u
Index: php-src/ext/zip/tests/zip_entry_read.phpt
diff -u php-src/ext/zip/tests/zip_entry_read.phpt:1.1 
php-src/ext/zip/tests/zip_entry_read.phpt:1.1.2.1
--- php-src/ext/zip/tests/zip_entry_read.phpt:1.1       Mon Jul 24 16:58:58 2006
+++ php-src/ext/zip/tests/zip_entry_read.phpt   Fri Nov  3 16:46:19 2006
@@ -2,7 +2,7 @@
 zip_entry_read() function
 --SKIPIF--
 <?php
-/* $Id: zip_entry_read.phpt,v 1.1 2006/07/24 16:58:58 pajoye Exp $ */
+/* $Id: zip_entry_read.phpt,v 1.1.2.1 2006/11/03 16:46:19 pajoye Exp $ */
 if(!extension_loaded('zip')) die('skip');
 ?>
 --FILE--
@@ -11,6 +11,7 @@
 $entry  = zip_read($zip);
 if (!zip_entry_open($zip, $entry, "r")) die("Failure");
 echo zip_entry_read($entry);
+zip_entry_close($entry);
 zip_close($zip);
 
 ?>

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 <[EMAIL PROTECTED]>

  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 <[EMAIL PROTECTED]>

  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 <[EMAIL PROTECTED]>

  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 <[EMAIL PROTECTED]>

  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;
}

http://cvs.php.net/viewvc.cgi/php-src/ext/zip/tests/oo_addemptydir.phpt?view=markup&rev=1.1
Index: php-src/ext/zip/tests/oo_addemptydir.phpt
+++ php-src/ext/zip/tests/oo_addemptydir.phpt
--TEST--
ziparchive::addEmptyDir
--SKIPIF--
<?php
/* $Id: oo_addemptydir.phpt,v 1.1 2006/11/01 19:56:53 pajoye Exp $ */
if(!extension_loaded('zip')) die('skip');
?>
--FILE--
<?php

$dirname = dirname(__FILE__) . '/';
include $dirname . 'utils.inc';
$file = $dirname . '__tmp_oo_addfile.zip';

copy($dirname . 'test.zip', $file);

$zip = new ZipArchive;
if (!$zip->open($file)) {
        exit('failed');
}

$zip->addEmptyDir('emptydir');
if ($zip->status == ZIPARCHIVE::ER_OK) {
        dump_entries_name($zip);
        $zip->close();
} else {
        echo "failed\n";
}
@unlink($file);
?>
--EXPECTF--
0 bar
1 foobar/
2 foobar/baz
3 entry1.txt
4 emptydir/

http://cvs.php.net/viewvc.cgi/php-src/ext/zip/tests/oo_extract.phpt?view=markup&rev=1.1
Index: php-src/ext/zip/tests/oo_extract.phpt
+++ php-src/ext/zip/tests/oo_extract.phpt
--TEST--
extractTo
--SKIPIF--
<?php
/* $Id: oo_extract.phpt,v 1.1 2006/10/30 17:43:21 pajoye Exp $ */
if(!extension_loaded('zip')) die('skip');
?>
--FILE--
<?php
$dirname = dirname(__FILE__) . '/';
$file = $dirname . 'test_with_comment.zip';
include $dirname . 'utils.inc';
$zip = new ZipArchive;
if (!$zip->open($file)) {
        exit('failed');
}


$zip->extractTo($dirname . '__oo_extract_tmp');
if (!is_dir($dirname . '__oo_extract_tmp')) {
        echo "failed. mkdir\n";
}

if (!is_dir($dirname .'__oo_extract_tmp/foobar')) {
        echo "failed. mkdir foobar\n";
}

if (!file_exists($dirname . '__oo_extract_tmp/foobar/baz')) {
        echo "failed. mkdir foobar\n";
} else {
        echo file_get_contents($dirname . '__oo_extract_tmp/foobar/baz') . "\n";
}

if (!file_exists($dirname . '__oo_extract_tmp/bar')) {
        echo "failed. bar file\n";
} else {
        echo file_get_contents($dirname . '__oo_extract_tmp/bar') . "\n";
}

if (!file_exists($dirname . '__oo_extract_tmp/foo')) {
        echo "failed. foo file\n";
} else {
        echo file_get_contents($dirname . '__oo_extract_tmp/foo') . "\n";
}


/* extract one file */
$zip->extractTo($dirname . '__oo_extract_tmp', 'bar');
if (!file_exists($dirname . '__oo_extract_tmp/bar')) {
        echo "failed. extract  bar file\n";
} else {
        echo file_get_contents($dirname . '__oo_extract_tmp/bar') . "\n";
}

/* extract two files */
$zip->extractTo($dirname . '__oo_extract_tmp', array('bar','foo'));
if (!file_exists($dirname . '__oo_extract_tmp/bar')) {
        echo "failed. extract  bar file\n";
} else {
        echo file_get_contents($dirname . '__oo_extract_tmp/bar') . "\n";
}
if (!file_exists($dirname . '__oo_extract_tmp/foo')) {
        echo "failed. extract foo file\n";
} else {
        echo file_get_contents($dirname . '__oo_extract_tmp/foo') . "\n";
}

rmdir_rf($dirname . '__oo_extract_tmp');
?>
--EXPECTF--
blabla laber rababer sülz

bar

foo


bar

bar

foo

http://cvs.php.net/viewvc.cgi/php-src/ext/zip/tests/oo_get_comment.phpt?view=markup&rev=1.1
Index: php-src/ext/zip/tests/oo_get_comment.phpt
+++ php-src/ext/zip/tests/oo_get_comment.phpt

http://cvs.php.net/viewvc.cgi/php-src/ext/zip/tests/oo_getnameindex.phpt?view=markup&rev=1.1
Index: php-src/ext/zip/tests/oo_getnameindex.phpt
+++ php-src/ext/zip/tests/oo_getnameindex.phpt
--TEST--
getNameIndex
--SKIPIF--
<?php
/* $Id: oo_getnameindex.phpt,v 1.1 2006/10/30 17:43:21 pajoye Exp $ */
if(!extension_loaded('zip')) die('skip');
?>
--FILE--
<?php
$dirname = dirname(__FILE__) . '/';
include $dirname . 'utils.inc';
$file = $dirname . '__tmp_oo_rename.zip';

@unlink($file);

$zip = new ZipArchive;
if (!$zip->open($file, ZIPARCHIVE::CREATE)) {
        exit('failed');
}

$zip->addFromString('entry1.txt', 'entry #1');
$zip->addFromString('entry2.txt', 'entry #2');
$zip->addFromString('dir/entry2d.txt', 'entry #2');

if (!$zip->status == ZIPARCHIVE::ER_OK) {
        echo "failed to write zip\n";
}
$zip->close();

if (!$zip->open($file)) {
        exit('failed');
}


var_dump($zip->getNameIndex(0));
var_dump($zip->getNameIndex(1));
var_dump($zip->getNameIndex(2));
var_dump($zip->getNameIndex(3));

$zip->close();

?>
--EXPECTF--
string(10) "entry1.txt"
string(10) "entry2.txt"
string(15) "dir/entry2d.txt"
bool(false)

http://cvs.php.net/viewvc.cgi/php-src/ext/zip/tests/oo_setcomment.phpt?view=markup&rev=1.1
Index: php-src/ext/zip/tests/oo_setcomment.phpt
+++ php-src/ext/zip/tests/oo_setcomment.phpt
--TEST--
setComment
--SKIPIF--
<?php
/* $Id: oo_setcomment.phpt,v 1.1 2006/10/30 17:43:21 pajoye Exp $ */
if(!extension_loaded('zip')) die('skip');
?>
--FILE--
<?php
$dirname = dirname(__FILE__) . '/';
include $dirname . 'utils.inc';
$file = $dirname . '__tmp_oo_set_comment.zip';

@unlink($file);

$zip = new ZipArchive;
if (!$zip->open($file, ZIPARCHIVE::CREATE)) {
        exit('failed');
}

$zip->addFromString('entry1.txt', 'entry #1');
$zip->addFromString('entry2.txt', 'entry #2');
$zip->addFromString('dir/entry2d.txt', 'entry #2');
$zip->addFromString('entry4.txt', 'entry #1');
$zip->addFromString('entry5.txt', 'entry #2');


var_dump($zip->setCommentName('entry1.txt', 'entry1.txt'));
var_dump($zip->setCommentName('entry2.txt', 'entry2.txt'));
var_dump($zip->setCommentName('dir/entry2d.txt', 'dir/entry2d.txt'));
var_dump($zip->setArchiveComment('archive'));

var_dump($zip->setCommentIndex(3, 'entry4.txt'));
var_dump($zip->setCommentIndex(4, 'entry5.txt'));
var_dump($zip->setArchiveComment('archive'));

if (!$zip->status == ZIPARCHIVE::ER_OK) {
        echo "failed to write zip\n";
}
$zip->close();

if (!$zip->open($file)) {
        @unlink($file);
        exit('failed');
}

var_dump($zip->getCommentIndex(0));
var_dump($zip->getCommentIndex(1));
var_dump($zip->getCommentIndex(2));
var_dump($zip->getCommentIndex(3));
var_dump($zip->getCommentIndex(4));
var_dump($zip->getArchiveComment());

$zip->close();
@unlink($file);

?>
--EXPECTF--
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
string(10) "entry1.txt"
string(10) "entry2.txt"
string(15) "dir/entry2d.txt"
string(10) "entry4.txt"
string(10) "entry5.txt"
string(7) "archive"

http://cvs.php.net/viewvc.cgi/php-src/ext/zip/tests/oo_stream.phpt?view=markup&rev=1.1
Index: php-src/ext/zip/tests/oo_stream.phpt
+++ php-src/ext/zip/tests/oo_stream.phpt
--TEST--
getStream
--SKIPIF--
<?php
/* $Id: oo_stream.phpt,v 1.1 2006/10/30 17:43:21 pajoye Exp $ */
if(!extension_loaded('zip')) die('skip');
?>
--FILE--
<?php
$dirname = dirname(__FILE__) . '/';
$file = $dirname . 'test_with_comment.zip';
include $dirname . 'utils.inc';
$zip = new ZipArchive;
if (!$zip->open($file)) {
        exit('failed');
}
$fp = $zip->getStream('foo');

var_dump($fp);
if(!$fp) exit("\n");
$contents = '';
while (!feof($fp)) {
        $contents .= fread($fp, 255);
}

fclose($fp);
$zip->close();
var_dump($contents);


$fp = fopen('zip://' . dirname(__FILE__) . '/test_with_comment.zip#foo', 'rb');
if (!$fp) {
  exit("cannot open\n");
}
$contents = '';
while (!feof($fp)) {
  $contents .= fread($fp, 2);
}
var_dump($contents);
fclose($fp);

?>
--EXPECTF--
resource(%d) of type (stream)
string(5) "foo

"
string(5) "foo

"

http://cvs.php.net/viewvc.cgi/php-src/ext/zip/tests/test_with_comment.zip?view=markup&rev=1.1
Index: php-src/ext/zip/tests/test_with_comment.zip
+++ php-src/ext/zip/tests/test_with_comment.zip
PK


PK

PK


E‰I`ºøðžœ*.




-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to