summaryrefslogtreecommitdiff
path: root/ext/spl/spl_directory.h
diff options
context:
space:
mode:
authorMarcus Boerger <helly@php.net>2008-02-02 23:09:38 +0000
committerMarcus Boerger <helly@php.net>2008-02-02 23:09:38 +0000
commitb628fc219aaf7961777389201d097061c01f23e1 (patch)
tree288b6b57d9e464323e9f8df9f6e878dbd7b03c81 /ext/spl/spl_directory.h
parent4904889568e6024d24ea52b07b8ec86dea5d1e6d (diff)
downloadphp-git-b628fc219aaf7961777389201d097061c01f23e1.tar.gz
- MFH Synch directory changes
[DOC] # Class FilesystemIterator was introduced to have a better DirectoryIterator # without having to change DirectoryIterator or RecursiveDirectoryIterator. # On top of FilterIterator the new GlobIterator was introduced. This one allows # to implement Countable(). But a glob stream flattens all structure, so it # cannot be derived from RedursiveIterator. With the new structure all children # of FilesystemIterator have nearly the same behavior. Just their capabilities # are a bit different. Check out new inheritance tree on SplFileInfo: # # [marcus@frodo PHP_5_3]$ php ext/spl/examples/class_tree.php SplFileInfo # make: `sapi/cli/php' is up to date. # SplFileInfo # |-DirectoryIterator (Iterator) # | \-FilesystemIterator # | |-GlobIterator (Countable) # | \-RecursiveDirectoryIterator (RecursiveIterator) # | \-Phar (ArrayAccess, Countable) # |-PharFileInfo # \-SplFileObject (RecursiveIterator, SeekableIterator) # \-SplTempFileObject
Diffstat (limited to 'ext/spl/spl_directory.h')
-rwxr-xr-xext/spl/spl_directory.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/ext/spl/spl_directory.h b/ext/spl/spl_directory.h
index 0764920512..aa15742a75 100755
--- a/ext/spl/spl_directory.h
+++ b/ext/spl/spl_directory.h
@@ -26,7 +26,9 @@
extern PHPAPI zend_class_entry *spl_ce_SplFileInfo;
extern PHPAPI zend_class_entry *spl_ce_DirectoryIterator;
+extern PHPAPI zend_class_entry *spl_ce_FilesystemIterator;
extern PHPAPI zend_class_entry *spl_ce_RecursiveDirectoryIterator;
+extern PHPAPI zend_class_entry *spl_ce_GlobIterator;
extern PHPAPI zend_class_entry *spl_ce_SplFileObject;
extern PHPAPI zend_class_entry *spl_ce_SplTempFileObject;
@@ -50,6 +52,13 @@ typedef struct _spl_other_handler {
spl_foreign_clone_t clone;
} spl_other_handler;
+/* define an overloaded iterator structure */
+typedef struct {
+ zend_object_iterator intern;
+ zval *current;
+ spl_filesystem_object *object;
+} spl_filesystem_iterator;
+
struct _spl_filesystem_object {
zend_object std;
void *oth;
@@ -89,8 +98,19 @@ struct _spl_filesystem_object {
char escape;
} file;
} u;
+ spl_filesystem_iterator it;
};
+static inline spl_filesystem_iterator* spl_filesystem_object_to_iterator(spl_filesystem_object *obj)
+{
+ return &obj->it;
+}
+
+static inline spl_filesystem_object* spl_filesystem_iterator_to_object(spl_filesystem_iterator *it)
+{
+ return (spl_filesystem_object*)((char*)it - XtOffsetOf(spl_filesystem_object, it));
+}
+
#define SPL_FILE_OBJECT_DROP_NEW_LINE 0x00000001 /* drop new lines */
#define SPL_FILE_OBJECT_READ_AHEAD 0x00000002 /* read on rewind/next */
#define SPL_FILE_OBJECT_SKIP_EMPTY 0x00000006 /* skip empty lines */