summaryrefslogtreecommitdiff
path: root/ext/zip/php_zip.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/zip/php_zip.c')
-rw-r--r--ext/zip/php_zip.c23
1 files changed, 6 insertions, 17 deletions
diff --git a/ext/zip/php_zip.c b/ext/zip/php_zip.c
index 6875850687..e62f9fc8f9 100644
--- a/ext/zip/php_zip.c
+++ b/ext/zip/php_zip.c
@@ -280,8 +280,7 @@ static int php_zip_add_file(ze_zip_object *obj, const char *filename, size_t fil
{
struct zip_source *zs;
char resolved_path[MAXPATHLEN];
- zval exists_flag;
-
+ php_stream_statbuf ssb;
if (ZIP_OPENBASEDIR_CHECKPATH(filename)) {
return -1;
@@ -292,8 +291,7 @@ static int php_zip_add_file(ze_zip_object *obj, const char *filename, size_t fil
return -1;
}
- php_stat(resolved_path, strlen(resolved_path), FS_EXISTS, &exists_flag);
- if (Z_TYPE(exists_flag) == IS_FALSE) {
+ if (php_stream_stat_path_ex(resolved_path, PHP_STREAM_URL_STAT_QUIET, &ssb, NULL)) {
php_error_docref(NULL, E_WARNING, "No such file or directory");
return -1;
}
@@ -831,17 +829,12 @@ static void php_zip_register_prop_handler(HashTable *prop_handler, char *name, z
{
zip_prop_handler hnd;
zend_string *str;
- zval tmp;
hnd.read_const_char_func = read_char_func;
hnd.read_int_func = read_int_func;
hnd.type = rettype;
str = zend_string_init_interned(name, strlen(name), 1);
zend_hash_add_mem(prop_handler, str, &hnd, sizeof(zip_prop_handler));
-
- /* Register for reflection */
- ZVAL_NULL(&tmp);
- zend_declare_property_ex(zip_class_entry, str, &tmp, ZEND_ACC_PUBLIC, NULL);
zend_string_release_ex(str, 1);
}
/* }}} */
@@ -2996,7 +2989,7 @@ PHP_METHOD(ZipArchive, registerCancelCallback)
PHP_METHOD(ZipArchive, isCompressionMethodSupported)
{
zend_long method;
- zend_bool enc = 1;
+ bool enc = 1;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l|b", &method, &enc) == FAILURE) {
return;
@@ -3009,7 +3002,7 @@ PHP_METHOD(ZipArchive, isCompressionMethodSupported)
PHP_METHOD(ZipArchive, isEncryptionMethodSupported)
{
zend_long method;
- zend_bool enc = 1;
+ bool enc = 1;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l|b", &method, &enc) == FAILURE) {
return;
@@ -3026,8 +3019,6 @@ static void php_zip_free_prop_handler(zval *el) /* {{{ */ {
/* {{{ PHP_MINIT_FUNCTION */
static PHP_MINIT_FUNCTION(zip)
{
- zend_class_entry ce;
-
memcpy(&zip_object_handlers, &std_object_handlers, sizeof(zend_object_handlers));
zip_object_handlers.offset = XtOffsetOf(ze_zip_object, zo);
zip_object_handlers.free_obj = php_zip_object_free_storage;
@@ -3039,9 +3030,8 @@ static PHP_MINIT_FUNCTION(zip)
zip_object_handlers.read_property = php_zip_read_property;
zip_object_handlers.has_property = php_zip_has_property;
- INIT_CLASS_ENTRY(ce, "ZipArchive", class_ZipArchive_methods);
- ce.create_object = php_zip_object_new;
- zip_class_entry = zend_register_internal_class(&ce);
+ zip_class_entry = register_class_ZipArchive(zend_ce_countable);
+ zip_class_entry->create_object = php_zip_object_new;
zend_hash_init(&zip_prop_handlers, 0, NULL, php_zip_free_prop_handler, 1);
php_zip_register_prop_handler(&zip_prop_handlers, "lastId", php_zip_last_id, NULL, IS_LONG);
@@ -3050,7 +3040,6 @@ static PHP_MINIT_FUNCTION(zip)
php_zip_register_prop_handler(&zip_prop_handlers, "numFiles", php_zip_get_num_files, NULL, IS_LONG);
php_zip_register_prop_handler(&zip_prop_handlers, "filename", NULL, php_zipobj_get_filename, IS_STRING);
php_zip_register_prop_handler(&zip_prop_handlers, "comment", NULL, php_zipobj_get_zip_comment, IS_STRING);
- zend_class_implements(zip_class_entry, 1, zend_ce_countable);
REGISTER_ZIP_CLASS_CONST_LONG("CREATE", ZIP_CREATE);
REGISTER_ZIP_CLASS_CONST_LONG("EXCL", ZIP_EXCL);