helly Sun Dec 11 16:43:00 2005 EDT
Modified files:
/php-src/ext/spl spl_directory.c
Log:
- 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.59&r2=1.60
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.59
php-src/ext/spl/spl_directory.c:1.60
--- php-src/ext/spl/spl_directory.c:1.59 Fri Dec 9 13:32:07 2005
+++ php-src/ext/spl/spl_directory.c Sun Dec 11 16:43:00 2005
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: spl_directory.c,v 1.59 2005/12/09 13:32:07 tony2001 Exp $ */
+/* $Id: spl_directory.c,v 1.60 2005/12/11 16:43:00 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, U_CLASS_ENTRY(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,
U_CLASS_ENTRY(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, U_CLASS_ENTRY(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,
U_CLASS_ENTRY(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)
@@ -1234,7 +1251,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