@@ -80,10 +80,10 @@ static int le_zip_entry;
80
80
#define PHP_ZIP_SET_FILE_COMMENT (za , index , comment , comment_len ) \
81
81
if (comment_len == 0) { \
82
82
/* Passing NULL remove the existing comment */ \
83
- if (zip_set_file_comment(intern , index, NULL, 0) < 0) { \
83
+ if (zip_set_file_comment(za , index, NULL, 0) < 0) { \
84
84
RETURN_FALSE; \
85
85
} \
86
- } else if (zip_set_file_comment(intern , index, comment, comment_len) < 0) { \
86
+ } else if (zip_set_file_comment(za , index, comment, comment_len) < 0) { \
87
87
RETURN_FALSE; \
88
88
} \
89
89
RETURN_TRUE;
@@ -1543,7 +1543,7 @@ static ZIPARCHIVE_METHOD(getStatusString)
1543
1543
RETVAL_STRINGL (error_string , len );
1544
1544
#else
1545
1545
err = zip_get_error (intern );
1546
- RETVAL_STRING (zip_error_strerror (err ), 1 );
1546
+ RETVAL_STRING (zip_error_strerror (err ));
1547
1547
zip_error_fini (err );
1548
1548
#endif
1549
1549
}
@@ -2275,6 +2275,73 @@ static ZIPARCHIVE_METHOD(getCommentIndex)
2275
2275
}
2276
2276
/* }}} */
2277
2277
2278
+ /* {{{ proto bool ZipArchive::setCompressionName(string name, int comp_method[, int comp_flags])
2279
+ Set the compression of a file in zip, using its name */
2280
+ static ZIPARCHIVE_METHOD (setCompressionName )
2281
+ {
2282
+ struct zip * intern ;
2283
+ zval * this = getThis ();
2284
+ size_t name_len ;
2285
+ char * name ;
2286
+ zip_int64_t idx ;
2287
+ zend_long comp_method , comp_flags = 0 ;
2288
+
2289
+ if (!this ) {
2290
+ RETURN_FALSE ;
2291
+ }
2292
+
2293
+ ZIP_FROM_OBJECT (intern , this );
2294
+
2295
+ if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "sl|l" ,
2296
+ & name , & name_len , & comp_method , & comp_flags ) == FAILURE ) {
2297
+ return ;
2298
+ }
2299
+
2300
+ if (name_len < 1 ) {
2301
+ php_error_docref (NULL TSRMLS_CC , E_NOTICE , "Empty string as entry name" );
2302
+ }
2303
+
2304
+ idx = zip_name_locate (intern , name , 0 );
2305
+ if (idx < 0 ) {
2306
+ RETURN_FALSE ;
2307
+ }
2308
+
2309
+ if (zip_set_file_compression (intern , (zip_uint64_t )idx ,
2310
+ (zip_int32_t )comp_method , (zip_uint32_t )comp_flags ) != 0 ) {
2311
+ RETURN_FALSE ;
2312
+ }
2313
+ RETURN_TRUE ;
2314
+ }
2315
+ /* }}} */
2316
+
2317
+ /* {{{ proto bool ZipArchive::setCompressionIndex(int index, int comp_method[, int comp_flags])
2318
+ Set the compression of a file in zip, using its index */
2319
+ static ZIPARCHIVE_METHOD (setCompressionIndex )
2320
+ {
2321
+ struct zip * intern ;
2322
+ zval * this = getThis ();
2323
+ zend_long index ;
2324
+ zend_long comp_method , comp_flags = 0 ;
2325
+
2326
+ if (!this ) {
2327
+ RETURN_FALSE ;
2328
+ }
2329
+
2330
+ ZIP_FROM_OBJECT (intern , this );
2331
+
2332
+ if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "ll|l" ,
2333
+ & index , & comp_method , & comp_flags ) == FAILURE ) {
2334
+ return ;
2335
+ }
2336
+
2337
+ if (zip_set_file_compression (intern , (zip_uint64_t )index ,
2338
+ (zip_int32_t )comp_method , (zip_uint32_t )comp_flags ) != 0 ) {
2339
+ RETURN_FALSE ;
2340
+ }
2341
+ RETURN_TRUE ;
2342
+ }
2343
+ /* }}} */
2344
+
2278
2345
/* {{{ proto bool ZipArchive::deleteIndex(int index)
2279
2346
Delete a file using its index */
2280
2347
static ZIPARCHIVE_METHOD (deleteIndex )
@@ -2870,6 +2937,18 @@ ZEND_END_ARG_INFO()
2870
2937
#endif /* ifdef ZIP_OPSYS_DEFAULT */
2871
2938
/* }}} */
2872
2939
2940
+ ZEND_BEGIN_ARG_INFO_EX (arginfo_ziparchive_setcompname , 0 , 0 , 2 )
2941
+ ZEND_ARG_INFO (0 , name )
2942
+ ZEND_ARG_INFO (0 , method )
2943
+ ZEND_ARG_INFO (0 , compflags )
2944
+ ZEND_END_ARG_INFO ()
2945
+
2946
+ ZEND_BEGIN_ARG_INFO_EX (arginfo_ziparchive_setcompindex , 0 , 0 , 2 )
2947
+ ZEND_ARG_INFO (0 , index )
2948
+ ZEND_ARG_INFO (0 , method )
2949
+ ZEND_ARG_INFO (0 , compflags )
2950
+ ZEND_END_ARG_INFO ()
2951
+
2873
2952
/* {{{ ze_zip_object_class_functions */
2874
2953
static const zend_function_entry zip_class_functions [] = {
2875
2954
ZIPARCHIVE_ME (open , arginfo_ziparchive_open , ZEND_ACC_PUBLIC )
@@ -2907,6 +2986,8 @@ static const zend_function_entry zip_class_functions[] = {
2907
2986
ZIPARCHIVE_ME (setExternalAttributesIndex , arginfo_ziparchive_setextattrindex , ZEND_ACC_PUBLIC )
2908
2987
ZIPARCHIVE_ME (getExternalAttributesName , arginfo_ziparchive_getextattrname , ZEND_ACC_PUBLIC )
2909
2988
ZIPARCHIVE_ME (getExternalAttributesIndex , arginfo_ziparchive_getextattrindex , ZEND_ACC_PUBLIC )
2989
+ ZIPARCHIVE_ME (setCompressionName , arginfo_ziparchive_setcompname , ZEND_ACC_PUBLIC )
2990
+ ZIPARCHIVE_ME (setCompressionIndex , arginfo_ziparchive_setcompindex , ZEND_ACC_PUBLIC )
2910
2991
{NULL , NULL , NULL }
2911
2992
};
2912
2993
/* }}} */
0 commit comments