pollita Mon Mar 1 00:40:15 2004 EDT Modified files: /php-src/ext/standard dir.c Log: context parameter for opendir() and dir() http://cvs.php.net/diff.php/php-src/ext/standard/dir.c?r1=1.134&r2=1.135&ty=u Index: php-src/ext/standard/dir.c diff -u php-src/ext/standard/dir.c:1.134 php-src/ext/standard/dir.c:1.135 --- php-src/ext/standard/dir.c:1.134 Wed Feb 25 15:16:26 2004 +++ php-src/ext/standard/dir.c Mon Mar 1 00:40:14 2004 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: dir.c,v 1.134 2004/02/25 20:16:26 abies Exp $ */ +/* $Id: dir.c,v 1.135 2004/03/01 05:40:14 pollita Exp $ */ /* {{{ includes/startup/misc */ @@ -175,15 +175,21 @@ /* {{{ internal functions */ static void _php_do_opendir(INTERNAL_FUNCTION_PARAMETERS, int createobject) { - pval **arg; + char *dirname; + long dir_len; + zval *zcontext = NULL; + php_stream_context *context = NULL; php_stream *dirp; - - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg) == FAILURE) { - WRONG_PARAM_COUNT; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|r", &dirname, &dir_len, &zcontext) == FAILURE) { + RETURN_NULL(); + } + + if (zcontext) { + context = php_stream_context_from_zval(zcontext, 0); } - convert_to_string_ex(arg); - dirp = php_stream_opendir(Z_STRVAL_PP(arg), ENFORCE_SAFE_MODE|REPORT_ERRORS, NULL); + dirp = php_stream_opendir(dirname, ENFORCE_SAFE_MODE|REPORT_ERRORS, context); if (dirp == NULL) { RETURN_FALSE; @@ -193,7 +199,7 @@ if (createobject) { object_init_ex(return_value, dir_class_entry_ptr); - add_property_stringl(return_value, "path", Z_STRVAL_PP(arg), Z_STRLEN_PP(arg), 1); + add_property_stringl(return_value, "path", dirname, dir_len, 1); add_property_resource(return_value, "handle", dirp->rsrc_id); php_stream_auto_cleanup(dirp); /* so we don't get warnings under debug */ } else { @@ -202,7 +208,7 @@ } /* }}} */ -/* {{{ proto mixed opendir(string path) +/* {{{ proto mixed opendir(string path[, resource context]) Open a directory and return a dir_handle */ PHP_FUNCTION(opendir) { @@ -210,7 +216,7 @@ } /* }}} */ -/* {{{ proto object dir(string directory) +/* {{{ proto object dir(string directory[, resource context]) Directory class with properties, handle and class and methods read, rewind and close */ PHP_FUNCTION(getdir) {
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php