From: Johannes Schlüter Date: Tue, 6 Feb 2007 23:56:39 +0000 (+0000) Subject: - Add possibility to check for a specific compression method X-Git-Tag: RELEASE_1_0_1~314 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=30dad44aa3be96d611cb499809b4f6cf31ffe9c0;p=php - Add possibility to check for a specific compression method --- diff --git a/ext/phar/phar_object.c b/ext/phar/phar_object.c index e3d4c23f0e..5a3f9c47c1 100755 --- a/ext/phar/phar_object.c +++ b/ext/phar/phar_object.c @@ -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 + } } /* }}} */