From: Johannes Schlüter Date: Mon, 25 Jan 2010 15:57:24 +0000 (+0000) Subject: merge r292595: Changed stream_resolve_include_path to use zend_resolve_path X-Git-Tag: php-5.3.2RC2~109 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c8a83ccbb7f80e97daa9a4d1676d5f423d5afbd2;p=php merge r292595: Changed stream_resolve_include_path to use zend_resolve_path (mkoppanen) --- diff --git a/NEWS b/NEWS index b45719fa0a..93284c5f94 100644 --- a/NEWS +++ b/NEWS @@ -29,6 +29,7 @@ PHP NEWS - Added support for CURLOPT_CERTINFO. FR #49253. (Linus Nielsen Feltzing ) - Added client-side server name indication support in openssl. (Arnaud) +- Added stream_resolve_include_path() (Mikko) - Improved fix for bug #50006 (Segfault caused by uksort()). (Stas) diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index 150afa1d18..f29df3cec3 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -2010,6 +2010,10 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO(arginfo_stream_get_wrappers, 0) ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_INFO(arginfo_stream_resolve_include_path, 0) + ZEND_ARG_INFO(0, filename) +ZEND_END_ARG_INFO() + ZEND_BEGIN_ARG_INFO(arginfo_stream_is_local, 0) ZEND_ARG_INFO(0, stream) ZEND_END_ARG_INFO() @@ -3115,6 +3119,7 @@ const zend_function_entry basic_functions[] = { /* {{{ */ PHP_FE(stream_wrapper_restore, arginfo_stream_wrapper_restore) PHP_FE(stream_get_wrappers, arginfo_stream_get_wrappers) PHP_FE(stream_get_transports, arginfo_stream_get_transports) + PHP_FE(stream_resolve_include_path, arginfo_stream_resolve_include_path) PHP_FE(stream_is_local, arginfo_stream_is_local) PHP_FE(get_headers, arginfo_get_headers) diff --git a/ext/standard/streamsfuncs.c b/ext/standard/streamsfuncs.c index c3f36aec3c..4f7027fa66 100644 --- a/ext/standard/streamsfuncs.c +++ b/ext/standard/streamsfuncs.c @@ -1442,6 +1442,26 @@ PHP_FUNCTION(stream_socket_enable_crypto) } /* }}} */ +/* {{{ proto string stream_resolve_include_path(string filename) +Determine what file will be opened by calls to fopen() with a relative path */ +PHP_FUNCTION(stream_resolve_include_path) +{ + char *filename, *resolved_path; + int filename_len; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &filename, &filename_len) == FAILURE) { + return; + } + + resolved_path = zend_resolve_path(filename, filename_len TSRMLS_CC); + + if (resolved_path) { + RETURN_STRING(resolved_path, 0); + } + RETURN_FALSE; +} +/* }}} */ + /* {{{ proto bool stream_is_local(resource stream|string url) U */ PHP_FUNCTION(stream_is_local) diff --git a/ext/standard/streamsfuncs.h b/ext/standard/streamsfuncs.h index c928bbb7d9..268be381b4 100644 --- a/ext/standard/streamsfuncs.h +++ b/ext/standard/streamsfuncs.h @@ -56,6 +56,7 @@ PHP_FUNCTION(stream_filter_append); PHP_FUNCTION(stream_filter_remove); PHP_FUNCTION(stream_socket_enable_crypto); PHP_FUNCTION(stream_socket_shutdown); +PHP_FUNCTION(stream_resolve_include_path); PHP_FUNCTION(stream_is_local); PHP_FUNCTION(stream_supports_lock); diff --git a/ext/standard/tests/streams/stream_resolve_include_path.phpt b/ext/standard/tests/streams/stream_resolve_include_path.phpt new file mode 100644 index 0000000000..01c05a5ca2 --- /dev/null +++ b/ext/standard/tests/streams/stream_resolve_include_path.phpt @@ -0,0 +1,37 @@ +--TEST-- +stream_resolve_include_path(string path) +--FILE-- +