From: Greg Beaver Date: Tue, 6 Feb 2007 05:41:18 +0000 (+0000) Subject: add PharFileInfo->chmod() to set permissions (no other way to do it) X-Git-Tag: RELEASE_1_0_0RC1~6 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=70dc64e95a8592839cd9635d89bea9656a8242bc;p=php add PharFileInfo->chmod() to set permissions (no other way to do it) --- diff --git a/ext/phar/phar_object.c b/ext/phar/phar_object.c index 68ff4a4587..3b1dc2adbe 100755 --- a/ext/phar/phar_object.c +++ b/ext/phar/phar_object.c @@ -880,13 +880,31 @@ PHP_METHOD(PharFileInfo, getPharFlags) } /* }}} */ +/* {{{ proto int PharFileInfo::chmod() + * set the file permissions for the Phar. This only allows setting execution bit, read/write + */ +PHP_METHOD(PharFileInfo, chmod) +{ + long perms; + PHAR_ENTRY_OBJECT(); + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &perms) == FAILURE) { + return; + } + /* clear permissions */ + entry_obj->ent.entry->flags &= ~PHAR_ENT_PERM_MASK; + perms &= 0777; + entry_obj->ent.entry->flags |= perms; +} +/* }}} */ + /* {{{ proto int PharFileInfo::getMetaData() * Returns the metadata of the entry */ PHP_METHOD(PharFileInfo, getMetadata) { PHAR_ENTRY_OBJECT(); - + if (entry_obj->ent.entry->metadata) { RETURN_ZVAL(entry_obj->ent.entry->metadata, 1, 0); } @@ -1144,6 +1162,7 @@ zend_function_entry php_entry_methods[] = { PHP_ME(PharFileInfo, getPharFlags, NULL, 0) PHP_ME(PharFileInfo, getMetadata, NULL, 0) PHP_ME(PharFileInfo, setMetadata, arginfo_entry_setMetadata, 0) + PHP_ME(PharFileInfo, chmod, arginfo_entry_setMetadata, 0) {NULL, NULL, NULL} }; #endif