diff options
Diffstat (limited to 'ext/zip/php_zip.c')
-rw-r--r-- | ext/zip/php_zip.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/ext/zip/php_zip.c b/ext/zip/php_zip.c index 394819cf34..2353519be4 100644 --- a/ext/zip/php_zip.c +++ b/ext/zip/php_zip.c @@ -28,6 +28,11 @@ #include "ext/standard/php_string.h" #include "ext/pcre/php_pcre.h" #include "ext/standard/php_filestat.h" +#if PHP_VERSION_ID >= 70200 +#include "zend_interfaces.h" +#elif defined(HAVE_SPL) +#include "ext/spl/spl_iterators.h" +#endif #include "php_zip.h" /* zip_open is a macro for renaming libzip zipopen, so we need to use PHP_NAMED_FUNCTION */ @@ -1548,6 +1553,23 @@ static ZIPARCHIVE_METHOD(close) } /* }}} */ +/* {{{ proto bool ZipArchive::count() +close the zip archive */ +static ZIPARCHIVE_METHOD(count) +{ + struct zip *intern; + zval *self = getThis(); + + if (!self) { + RETURN_FALSE; + } + + ZIP_FROM_OBJECT(intern, self); + + RETVAL_LONG(zip_get_num_files(intern)); +} +/* }}} */ + /* {{{ proto string ZipArchive::getStatusString() * Returns the status error message, system and/or zip messages */ static ZIPARCHIVE_METHOD(getStatusString) @@ -3069,6 +3091,7 @@ static const zend_function_entry zip_class_functions[] = { ZIPARCHIVE_ME(open, arginfo_ziparchive_open, ZEND_ACC_PUBLIC) ZIPARCHIVE_ME(setPassword, arginfo_ziparchive_setpassword, ZEND_ACC_PUBLIC) ZIPARCHIVE_ME(close, arginfo_ziparchive__void, ZEND_ACC_PUBLIC) + ZIPARCHIVE_ME(count, arginfo_ziparchive__void, ZEND_ACC_PUBLIC) ZIPARCHIVE_ME(getStatusString, arginfo_ziparchive__void, ZEND_ACC_PUBLIC) ZIPARCHIVE_ME(addEmptyDir, arginfo_ziparchive_addemptydir, ZEND_ACC_PUBLIC) ZIPARCHIVE_ME(addFromString, arginfo_ziparchive_addfromstring, ZEND_ACC_PUBLIC) @@ -3141,6 +3164,11 @@ static PHP_MINIT_FUNCTION(zip) php_zip_register_prop_handler(&zip_prop_handlers, "numFiles", php_zip_get_num_files, NULL, NULL, IS_LONG); php_zip_register_prop_handler(&zip_prop_handlers, "filename", NULL, NULL, php_zipobj_get_filename, IS_STRING); php_zip_register_prop_handler(&zip_prop_handlers, "comment", NULL, php_zipobj_get_zip_comment, NULL, IS_STRING); +#if PHP_VERSION_ID >= 70200 + zend_class_implements(zip_class_entry, 1, zend_ce_countable); +#elif defined(HAVE_SPL) + zend_class_implements(zip_class_entry, 1, spl_ce_Countable); +#endif REGISTER_ZIP_CLASS_CONST_LONG("CREATE", ZIP_CREATE); REGISTER_ZIP_CLASS_CONST_LONG("EXCL", ZIP_EXCL); |