summaryrefslogtreecommitdiff
path: root/ext/standard/dir.c
diff options
context:
space:
mode:
authorSara Golemon <pollita@php.net>2004-03-01 05:40:14 +0000
committerSara Golemon <pollita@php.net>2004-03-01 05:40:14 +0000
commitd9d38900b6da98c96f4cbf05f7f3a461fe825d93 (patch)
treed2d990d5fa345d4c82e92dd22868cc110303ea96 /ext/standard/dir.c
parent860daac5d8ab2156b1ce31be52b822f6020b3c12 (diff)
downloadphp-git-d9d38900b6da98c96f4cbf05f7f3a461fe825d93.tar.gz
context parameter for opendir() and dir()
Diffstat (limited to 'ext/standard/dir.c')
-rw-r--r--ext/standard/dir.c24
1 files changed, 15 insertions, 9 deletions
diff --git a/ext/standard/dir.c b/ext/standard/dir.c
index b8a8992fac..9632445854 100644
--- a/ext/standard/dir.c
+++ b/ext/standard/dir.c
@@ -175,15 +175,21 @@ PHP_MINIT_FUNCTION(dir)
/* {{{ 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 @@ static void _php_do_opendir(INTERNAL_FUNCTION_PARAMETERS, int createobject)
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 @@ static void _php_do_opendir(INTERNAL_FUNCTION_PARAMETERS, int createobject)
}
/* }}} */
-/* {{{ 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 @@ PHP_FUNCTION(opendir)
}
/* }}} */
-/* {{{ 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)
{