cvs: pecl /phar phar_object.c
| From: | Greg Beaver | Date: | Mon, 21 Jan 2008 05:28:09 +0000 |
| Subject: | cvs: pecl /phar phar_object.c | ||
| Groups: | php.pecl.cvs | ||
| Request: | Send a blank email to pecl-cvs+get-9575@lists.php.net to get a copy of this message | ||
cellog Mon Jan 21 05:28:09 2008 UTC
Modified files:
/pecl/phar phar_object.c
Log:
fix problems found while documenting. Throw consistent exceptions, chmod is not allowed on
temporary directories, but is allowed on regular ones
allow uncompressAllFiles() to decompress a gzip/bzipped tar archive
fix some protos
http://cvs.php.net/viewvc.cgi/pecl/phar/phar_object.c?r1=1.131&r2=1.132&diff_format=u
Index: pecl/phar/phar_object.c
diff -u pecl/phar/phar_object.c:1.131 pecl/phar/phar_object.c:1.132
--- pecl/phar/phar_object.c:1.131 Sun Jan 20 00:49:44 2008
+++ pecl/phar/phar_object.c Mon Jan 21 05:28:08 2008
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: phar_object.c,v 1.131 2008/01/20 00:49:44 cellog Exp $ */
+/* $Id: phar_object.c,v 1.132 2008/01/21 05:28:08 cellog Exp $ */
#include "phar_internal.h"
#include "func_interceptors.h"
@@ -1923,7 +1923,7 @@
}
/* }}} */
-/* {{{ proto bool Phar::isCompressed()
+/* {{{ proto int|false Phar::isCompressed()
* Returns Phar::GZ or PHAR::BZ2 if the entire phar archive is compressed (.tar.gz/tar.bz and so
on)
*/
PHP_METHOD(Phar, isCompressed)
@@ -1936,7 +1936,7 @@
if (phar_obj->arc.archive->flags & PHAR_FILE_COMPRESSED_BZ2) {
RETURN_LONG(PHAR_ENT_COMPRESSED_BZ2);
}
- RETURN_LONG(0);
+ RETURN_FALSE;
}
/* }}} */
@@ -2180,6 +2180,11 @@
"Cannot set signature algorithm, not possible with tar-based phar archives");
return;
}
+ if (phar_obj->arc.archive->is_zip) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
+ "Cannot set signature algorithm, not possible with zip-based phar archives");
+ return;
+ }
if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "l",
&algo) != SUCCESS) {
return;
@@ -2201,7 +2206,7 @@
phar_flush(phar_obj->arc.archive, 0, 0, &error TSRMLS_CC);
if (error) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, error);
+ zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, error);
efree(error);
}
break;
@@ -2407,7 +2412,11 @@
"Cannot uncompress all files, some are compressed as bzip2 or gzip and cannot be
uncompressed");
return;
}
- pharobj_set_compression(&phar_obj->arc.archive->manifest, PHAR_ENT_COMPRESSED_NONE
TSRMLS_CC);
+ if (phar_obj->arc.archive->is_tar) {
+ phar_obj->arc.archive->flags &= ~PHAR_FILE_COMPRESSION_MASK;
+ } else {
+ pharobj_set_compression(&phar_obj->arc.archive->manifest, PHAR_ENT_COMPRESSED_NONE
TSRMLS_CC);
+ }
phar_obj->arc.archive->is_modified = 1;
phar_flush(phar_obj->arc.archive, 0, 0, &error TSRMLS_CC);
@@ -2834,6 +2843,10 @@
zval *metadata;
PHAR_ARCHIVE_OBJECT();
+ if (PHAR_G(readonly)) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Write operations
disabled by INI setting");
+ return;
+ }
if (phar_obj->arc.archive->is_tar) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
"Cannot set metadata, not possible with tar-based phar archives");
@@ -2859,7 +2872,7 @@
}
/* }}} */
-/* {{{ proto int Phar::delMetaData()
+/* {{{ proto int Phar::delMetadata()
* Deletes the global metadata of the phar
*/
PHP_METHOD(Phar, delMetadata)
@@ -2867,6 +2880,10 @@
char *error;
PHAR_ARCHIVE_OBJECT();
+ if (PHAR_G(readonly)) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Write operations
disabled by INI setting");
+ return;
+ }
if (phar_obj->arc.archive->metadata) {
zval_ptr_dtor(&phar_obj->arc.archive->metadata);
phar_obj->arc.archive->metadata = NULL;
@@ -3150,6 +3167,10 @@
zval *metadata;
PHAR_ENTRY_OBJECT();
+ if (PHAR_G(readonly)) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Write operations
disabled by INI setting");
+ return;
+ }
if (entry_obj->ent.entry->is_tar) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
"Cannot set metadata, not possible with tar-based phar archives");
@@ -3188,11 +3209,13 @@
char *error;
PHAR_ENTRY_OBJECT();
- if (entry_obj->ent.entry->is_dir) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, \
- "Phar entry is a directory, cannot delete metadata"); \
+ if (PHAR_G(readonly)) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Write operations
disabled by INI setting");
return;
}
+ if (entry_obj->ent.entry->is_temp_dir) {
+ RETURN_FALSE;
+ }
if (entry_obj->ent.entry->metadata) {
zval_ptr_dtor(&entry_obj->ent.entry->metadata);
entry_obj->ent.entry->metadata = NULL;