helly Sun Nov 9 18:00:51 2003 EDT
Modified files:
/spl spl_directory.c
Log:
Synch exposed functions with c-level iterator functions
Index: spl/spl_directory.c
diff -u spl/spl_directory.c:1.11 spl/spl_directory.c:1.12
--- spl/spl_directory.c:1.11 Sun Nov 9 09:05:35 2003
+++ spl/spl_directory.c Sun Nov 9 18:00:50 2003
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: spl_directory.c,v 1.11 2003/11/09 14:05:35 helly Exp $ */
+/* $Id: spl_directory.c,v 1.12 2003/11/09 23:00:50 helly Exp $ */
#ifdef HAVE_CONFIG_H
# include "config.h"
@@ -53,6 +53,8 @@
SPL_METHOD(DirectoryIterator, isDot);
SPL_METHOD(DirectoryIterator, isDir);
+SPL_METHOD(DirectoryTreeIterator, rewind);
+SPL_METHOD(DirectoryTreeIterator, next);
SPL_METHOD(DirectoryTreeIterator, key);
SPL_METHOD(DirectoryTreeIterator, hasChildren);
SPL_METHOD(DirectoryTreeIterator, getChildren);
@@ -84,6 +86,8 @@
};
static zend_function_entry spl_ce_dir_tree_class_functions[] = {
+ SPL_ME(DirectoryTreeIterator, rewind, NULL, ZEND_ACC_PUBLIC)
+ SPL_ME(DirectoryTreeIterator, next, NULL, ZEND_ACC_PUBLIC)
SPL_ME(DirectoryTreeIterator, key, NULL, ZEND_ACC_PUBLIC)
SPL_ME(DirectoryTreeIterator, hasChildren, NULL, ZEND_ACC_PUBLIC)
SPL_ME(DirectoryTreeIterator, getChildren, NULL, ZEND_ACC_PUBLIC)
@@ -400,7 +404,42 @@
}
/* }}} */
-/* {{{ proto bool DirectoryIterator::hasChildren()
+/* {{{ proto void DirectoryTreeIterator::rewind()
+ Rewind dir back to the start */
+SPL_METHOD(DirectoryTreeIterator, rewind)
+{
+ zval *object = getThis();
+ spl_ce_dir_object *intern =
(spl_ce_dir_object*)zend_object_store_get_object(object TSRMLS_CC);
+
+ intern->index = 0;
+ if (intern->dirp) {
+ php_stream_rewinddir(intern->dirp);
+ }
+ do {
+ if (!intern->dirp || !php_stream_readdir(intern->dirp,
&intern->entry)) {
+ intern->entry.d_name[0] = '\0';
+ }
+ } while (!strcmp(intern->entry.d_name, ".") || !strcmp(intern->entry.d_name,
".."));
+}
+/* }}} */
+
+/* {{{ proto void DirectoryTreeIterator::next()
+ Move to next entry */
+SPL_METHOD(DirectoryTreeIterator, next)
+{
+ zval *object = getThis();
+ spl_ce_dir_object *intern =
(spl_ce_dir_object*)zend_object_store_get_object(object TSRMLS_CC);
+
+ intern->index++;
+ do {
+ if (!intern->dirp || !php_stream_readdir(intern->dirp,
&intern->entry)) {
+ intern->entry.d_name[0] = '\0';
+ }
+ } while (!strcmp(intern->entry.d_name, ".") || !strcmp(intern->entry.d_name,
".."));
+}
+/* }}} */
+
+/* {{{ proto bool DirectoryTreeIterator::hasChildren()
Returns whether current entry is a directory and not '.' or '..' */
SPL_METHOD(DirectoryTreeIterator, hasChildren)
{
@@ -419,7 +458,7 @@
}
/* }}} */
-/* {{{ proto DirectoryIterator DirectoryIterator::getChildren()
+/* {{{ proto DirectoryTreeIterator DirectoryIterator::getChildren()
Returns an iterator fo rthe current entry if it is a directory */
SPL_METHOD(DirectoryTreeIterator, getChildren)
{
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php