helly Sun Dec 11 16:43:29 2005 EDT Modified files: (Branch: PHP_5_1) /php-src/ext/spl spl_directory.c Log: MFH: . Change to use sane default flags fro RecursiveDirectoryIterator . Drop 2nd parameter from DirectoryIterator::__construct() http://cvs.php.net/diff.php/php-src/ext/spl/spl_directory.c?r1=1.45.2.6&r2=1.45.2.7 Index: php-src/ext/spl/spl_directory.c diff -u php-src/ext/spl/spl_directory.c:1.45.2.6 php-src/ext/spl/spl_directory.c:1.45.2.7 --- php-src/ext/spl/spl_directory.c:1.45.2.6 Fri Dec 9 13:28:10 2005 +++ php-src/ext/spl/spl_directory.c Sun Dec 11 16:43:29 2005 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: spl_directory.c,v 1.45.2.6 2005/12/09 13:28:10 tony2001 Exp $ */ +/* $Id: spl_directory.c,v 1.45.2.7 2005/12/11 16:43:29 helly Exp $ */ #ifdef HAVE_CONFIG_H # include "config.h" @@ -377,25 +377,17 @@ return NULL; } /* }}} */ -/* {{{ proto void DirectoryIterator::__construct(string path [, int flags]) +/* {{{ proto void DirectoryIterator::__construct(string path) Cronstructs a new dir iterator from a path. */ -/* php_set_error_handling() is used to throw exceptions in case - the constructor fails. Here we use this to ensure the object - has a valid directory resource. - - When the constructor gets called the object is already created - by the engine, so we must only call 'additional' initializations. - */ SPL_METHOD(DirectoryIterator, __construct) { spl_filesystem_object *intern; char *path; int len; - long flags = 0; php_set_error_handling(EH_THROW, spl_ce_RuntimeException TSRMLS_CC); - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &path, &len, &flags) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &path, &len) == FAILURE) { php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC); return; } @@ -403,7 +395,7 @@ intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC); spl_filesystem_dir_open(intern, path TSRMLS_CC); intern->u.dir.is_recursive = instanceof_function(intern->std.ce, spl_ce_RecursiveDirectoryIterator TSRMLS_CC) ? 1 : 0; - intern->flags = flags; + intern->flags = 0; php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC); } @@ -544,7 +536,7 @@ /* }}} */ /* {{{ proto string RecursiveDirectoryIterator::current() - Return getFilename() or getFileInfo() depending on flags */ + Return getFilename(), getFileInfo() or $this depending on flags */ SPL_METHOD(RecursiveDirectoryIterator, current) { spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC); @@ -755,6 +747,31 @@ spl_filesystem_object_create_info(intern, intern->path, intern->path_len, 1, ce, return_value TSRMLS_CC); } +/* {{{ proto void RecursiveDirectoryIterator::__construct(string path [, int flags]) + Cronstructs a new dir iterator from a path. */ +SPL_METHOD(RecursiveDirectoryIterator, __construct) +{ + spl_filesystem_object *intern; + char *path; + int len; + long flags = SPL_FILE_DIR_CURRENT_AS_FILEINFO; + + php_set_error_handling(EH_THROW, spl_ce_RuntimeException TSRMLS_CC); + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &path, &len, &flags) == FAILURE) { + php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC); + return; + } + + intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC); + spl_filesystem_dir_open(intern, path TSRMLS_CC); + intern->u.dir.is_recursive = instanceof_function(intern->std.ce, spl_ce_RecursiveDirectoryIterator TSRMLS_CC) ? 1 : 0; + intern->flags = flags; + + php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC); +} +/* }}} */ + /* {{{ proto void RecursiveDirectoryIterator::rewind() Rewind dir back to the start */ SPL_METHOD(RecursiveDirectoryIterator, rewind) @@ -1238,7 +1255,14 @@ {NULL, NULL, NULL} }; +static +ZEND_BEGIN_ARG_INFO(arginfo_r_dir___construct, 0) + ZEND_ARG_INFO(0, path) + ZEND_ARG_INFO(0, flags) +ZEND_END_ARG_INFO(); + static zend_function_entry spl_RecursiveDirectoryIterator_functions[] = { + SPL_ME(RecursiveDirectoryIterator, __construct, arginfo_r_dir___construct, ZEND_ACC_PUBLIC) SPL_ME(RecursiveDirectoryIterator, rewind, NULL, ZEND_ACC_PUBLIC) SPL_ME(RecursiveDirectoryIterator, next, NULL, ZEND_ACC_PUBLIC) SPL_ME(RecursiveDirectoryIterator, key, NULL, ZEND_ACC_PUBLIC)
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php