helly           Wed Feb 13 12:05:34 2008 UTC

  Added files:                 (Branch: PHP_5_3)
    /php-src/ext/spl/tests      dit_002.phpt 

  Modified files:              
    /php-src/ext/spl    spl.php spl_directory.c spl_directory.h 
  Log:
  - MFH Make this behave like in <= 5.2.5 and test for it
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl.php?r1=1.49.2.11.2.7.2.3&r2=1.49.2.11.2.7.2.4&diff_format=u
Index: php-src/ext/spl/spl.php
diff -u php-src/ext/spl/spl.php:1.49.2.11.2.7.2.3 
php-src/ext/spl/spl.php:1.49.2.11.2.7.2.4
--- php-src/ext/spl/spl.php:1.49.2.11.2.7.2.3   Mon Feb  4 21:37:47 2008
+++ php-src/ext/spl/spl.php     Wed Feb 13 12:05:34 2008
@@ -1030,8 +1030,8 @@
  */
 class RecursiveDirectoryIterator extends DirectoryIterator implements 
RecursiveIterator
 {
-       const CURRENT_AS_SELF       0x00000000; /* make 
RecursiveDirectoryTree::current() return getSelf() */
-       const CURRENT_AS_FILEINFO   0x00000010; /* make 
RecursiveDirectoryTree::current() return SplFileInfo */
+       const CURRENT_AS_FILEINFO   0x00000000; /* make 
RecursiveDirectoryTree::current() return SplFileInfo */
+       const CURRENT_AS_SELF       0x00000010; /* make 
RecursiveDirectoryTree::current() return getSelf() */
        const CURRENT_AS_PATHNAME   0x00000020; /* make 
RecursiveDirectoryTree::current() return getPathname() */
 
        const KEY_AS_PATHNAME       0x00000000; /* make 
RecursiveDirectoryTree::key() return getPathname() */
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_directory.c?r1=1.45.2.27.2.23.2.16&r2=1.45.2.27.2.23.2.17&diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.45.2.27.2.23.2.16 
php-src/ext/spl/spl_directory.c:1.45.2.27.2.23.2.17
--- php-src/ext/spl/spl_directory.c:1.45.2.27.2.23.2.16 Mon Feb  4 19:40:49 2008
+++ php-src/ext/spl/spl_directory.c     Wed Feb 13 12:05:34 2008
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: spl_directory.c,v 1.45.2.27.2.23.2.16 2008/02/04 19:40:49 helly Exp $ 
*/
+/* $Id: spl_directory.c,v 1.45.2.27.2.23.2.17 2008/02/13 12:05:34 helly Exp $ 
*/
 
 #ifdef HAVE_CONFIG_H
 # include "config.h"
@@ -556,7 +556,7 @@
        php_set_error_handling(EH_THROW, spl_ce_UnexpectedValueException 
TSRMLS_CC);
 
        if (ctor_flags & DIT_CTOR_FLAGS) {
-               flags = 0;
+               flags = 
SPL_FILE_DIR_KEY_AS_PATHNAME|SPL_FILE_DIR_CURRENT_AS_FILEINFO;
                parsed = zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, 
"s|l", &path, &len, &flags);
        } else {
                flags = 
SPL_FILE_DIR_KEY_AS_PATHNAME|SPL_FILE_DIR_CURRENT_AS_SELF;
@@ -1108,6 +1108,28 @@
 }
 /* }}} */
 
+/* {{{ proto int FilesystemIterator::getFlags()
+   Get handling flags */
+SPL_METHOD(FilesystemIterator, getFlags)
+{
+       spl_filesystem_object *intern = 
(spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
+
+       RETURN_LONG(intern->flags);
+} /* }}} */
+
+/* {{{ proto void FilesystemIterator::setFlags(long $flags)
+   Set handling flags */
+SPL_METHOD(FilesystemIterator, setFlags)
+{
+       spl_filesystem_object *intern = 
(spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
+       long flags;
+
+       zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &flags);
+
+       intern->flags &= 
~(SPL_FILE_DIR_KEY_MODE_MASK|SPL_FILE_DIR_CURRENT_MODE_MASK);
+       intern->flags |= 
((SPL_FILE_DIR_KEY_MODE_MASK|SPL_FILE_DIR_CURRENT_MODE_MASK) & flags);
+} /* }}} */
+
 /* {{{ proto bool RecursiveDirectoryIterator::hasChildren([bool $allow_links = 
false])
    Returns whether current entry is a directory and not '.' or '..' */
 SPL_METHOD(RecursiveDirectoryIterator, hasChildren)
@@ -1575,12 +1597,19 @@
        ZEND_ARG_INFO(0, allow_links)
 ZEND_END_ARG_INFO()
 
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_r_dir_setFlags, 0, 0, 0)
+       ZEND_ARG_INFO(0, flags)
+ZEND_END_ARG_INFO()
+
 static const zend_function_entry spl_FilesystemIterator_functions[] = {
        SPL_ME(FilesystemIterator, __construct,   arginfo_r_dir___construct, 
ZEND_ACC_PUBLIC)
        SPL_ME(FilesystemIterator, rewind,        NULL, ZEND_ACC_PUBLIC)
        SPL_ME(FilesystemIterator, next,          NULL, ZEND_ACC_PUBLIC)
        SPL_ME(FilesystemIterator, key,           NULL, ZEND_ACC_PUBLIC)
        SPL_ME(FilesystemIterator, current,       NULL, ZEND_ACC_PUBLIC)
+       SPL_ME(FilesystemIterator, getFlags,      NULL, ZEND_ACC_PUBLIC)
+       SPL_ME(FilesystemIterator, setFlags,      arginfo_r_dir_setFlags, 
ZEND_ACC_PUBLIC)
        {NULL, NULL, NULL}
 };
 
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_directory.h?r1=1.12.2.5.2.4.2.7&r2=1.12.2.5.2.4.2.8&diff_format=u
Index: php-src/ext/spl/spl_directory.h
diff -u php-src/ext/spl/spl_directory.h:1.12.2.5.2.4.2.7 
php-src/ext/spl/spl_directory.h:1.12.2.5.2.4.2.8
--- php-src/ext/spl/spl_directory.h:1.12.2.5.2.4.2.7    Mon Feb  4 21:37:47 2008
+++ php-src/ext/spl/spl_directory.h     Wed Feb 13 12:05:34 2008
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: spl_directory.h,v 1.12.2.5.2.4.2.7 2008/02/04 21:37:47 helly Exp $ */
+/* $Id: spl_directory.h,v 1.12.2.5.2.4.2.8 2008/02/13 12:05:34 helly Exp $ */
 
 #ifndef SPL_DIRECTORY_H
 #define SPL_DIRECTORY_H
@@ -116,8 +116,8 @@
 #define SPL_FILE_OBJECT_SKIP_EMPTY         0x00000006 /* skip empty lines */
 #define SPL_FILE_OBJECT_READ_CSV           0x00000008 /* read via fgetcsv */
 
-#define SPL_FILE_DIR_CURRENT_AS_SELF       0x00000000 /* make 
RecursiveDirectoryTree::current() return getSelf() */
-#define SPL_FILE_DIR_CURRENT_AS_FILEINFO   0x00000010 /* make 
RecursiveDirectoryTree::current() return SplFileInfo */
+#define SPL_FILE_DIR_CURRENT_AS_FILEINFO   0x00000000 /* make 
RecursiveDirectoryTree::current() return SplFileInfo */
+#define SPL_FILE_DIR_CURRENT_AS_SELF       0x00000010 /* make 
RecursiveDirectoryTree::current() return getSelf() */
 #define SPL_FILE_DIR_CURRENT_AS_PATHNAME   0x00000020 /* make 
RecursiveDirectoryTree::current() return getPathname() */
 #define SPL_FILE_DIR_CURRENT_MODE_MASK     0x000000F0 /* mask 
RecursiveDirectoryTree::current() */
 #define SPL_FILE_DIR_CURRENT(intern,mode)  
((intern->flags&SPL_FILE_DIR_CURRENT_MODE_MASK)==mode)

http://cvs.php.net/viewvc.cgi/php-src/ext/spl/tests/dit_002.phpt?view=markup&rev=1.1
Index: php-src/ext/spl/tests/dit_002.phpt
+++ php-src/ext/spl/tests/dit_002.phpt
--TEST--
SPL: DirectoryIterator defaults
--SKIPIF--
<?php if (!extension_loaded("spl")) print "skip"; ?>
--FILE--
<?php

$classes = array(
        'DirectoryIterator' => 0,
        'FilesystemIterator' => 1,
        'RecursiveDirectoryIterator' => 1,
        'GlobIterator' => 1,
);

foreach ($classes as $class => $flags) {
        echo "===$class===\n";
        $ref = new ReflectionClass($class);
        $obj = $ref->newInstance('glob://*');
        echo get_class($obj->current()) . "\n";
        if ($flags)
        {
                var_dump($obj->getFlags());
                $flags = array(
                        FilesystemIterator::CURRENT_AS_FILEINFO => 0,
                        FilesystemIterator::CURRENT_AS_SELF     => 0,
                        FilesystemIterator::CURRENT_AS_PATHNAME => 1,
                );
                foreach($flags as $flag => $isstring) {
                        $obj->setFlags($flag);
                        $obj->rewind();
                        var_dump($obj->getFlags());
                        if ($isstring) {
                                $val = $obj->current();
                                if (is_string($val) || is_unicode($val)) {
                                        var_dump(true);
                                } else {
                                        var_dump($val);
                                }
                        } else {
                                echo get_class($obj->current()) . "\n";
                        }
                }
        }
}
?>
===DONE===
--EXPECT--
===DirectoryIterator===
DirectoryIterator
===FilesystemIterator===
SplFileInfo
int(0)
int(0)
SplFileInfo
int(16)
FilesystemIterator
int(32)
bool(true)
===RecursiveDirectoryIterator===
SplFileInfo
int(0)
int(0)
SplFileInfo
int(16)
RecursiveDirectoryIterator
int(32)
bool(true)
===GlobIterator===
SplFileInfo
int(0)
int(0)
SplFileInfo
int(16)
GlobIterator
int(32)
bool(true)
===DONE===

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to