]> granicus.if.org Git - php/commitdiff
- Add possibility to check for a specific compression method
authorJohannes Schlüter <johannes@php.net>
Tue, 6 Feb 2007 23:56:39 +0000 (23:56 +0000)
committerJohannes Schlüter <johannes@php.net>
Tue, 6 Feb 2007 23:56:39 +0000 (23:56 +0000)
ext/phar/phar_object.c

index e3d4c23f0e1a1621bd1b3d8c01f7cb3d3cb5575f..5a3f9c47c1cb3856a2ef56a1a3bf560ecd19e038 100755 (executable)
@@ -70,15 +70,38 @@ PHP_METHOD(Phar, apiVersion)
 }
 /* }}}*/
 
-/* {{{ proto bool Phar::canCompress()
+/* {{{ proto bool Phar::canCompress([int method])
  * Returns whether phar extension supports compression using zlib/bzip2 */
 PHP_METHOD(Phar, canCompress)
 {
+       long method = 0;
+
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &method) == FAILURE) {
+               return;
+       }
+
+       switch (method) {
+       case PHAR_ENT_COMPRESSED_GZ:
+#if HAVE_ZLIB
+               RETURN_TRUE;
+#else
+               RETURN_FALSE;
+#endif
+
+       case PHAR_ENT_COMPRESSED_BZ2:
+#if HAVE_BZ2
+               RETURN_TRUE;
+#else
+               RETURN_FALSE;
+#endif
+
+       default:
 #if HAVE_ZLIB || HAVE_BZ2
-       RETURN_TRUE;
+               RETURN_TRUE;
 #else
-       RETURN_FALSE;
+               RETURN_FALSE;
 #endif
+       }
 }
 /* }}} */