From 30dad44aa3be96d611cb499809b4f6cf31ffe9c0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Johannes=20Schl=C3=BCter?= Date: Tue, 6 Feb 2007 23:56:39 +0000 Subject: [PATCH] - Add possibility to check for a specific compression method --- ext/phar/phar_object.c | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) 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 + } } /* }}} */ -- 2.50.1