sfox            Thu Jul 24 08:55:53 2008 UTC

  Modified files:              (Branch: PHP_5_3)
    /php-src/ext/spl    spl_directory.c spl_directory.h 
  Log:
  MFH SPL_FILE_DIR_UNIXPATHS.
  
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_directory.c?r1=1.45.2.27.2.23.2.26&r2=1.45.2.27.2.23.2.27&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.26 
php-src/ext/spl/spl_directory.c:1.45.2.27.2.23.2.27
--- php-src/ext/spl/spl_directory.c:1.45.2.27.2.23.2.26 Wed Jul 23 06:12:29 2008
+++ php-src/ext/spl/spl_directory.c     Thu Jul 24 08:55:52 2008
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: spl_directory.c,v 1.45.2.27.2.23.2.26 2008/07/23 06:12:29 helly Exp $ 
*/
+/* $Id: spl_directory.c,v 1.45.2.27.2.23.2.27 2008/07/24 08:55:52 sfox Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include "config.h"
@@ -175,6 +175,8 @@
 
 static inline void spl_filesystem_object_get_file_name(spl_filesystem_object 
*intern TSRMLS_DC) /* {{{ */
 {
+       char slash = intern->flags & SPL_FILE_DIR_UNIXPATHS ? '/' : 
DEFAULT_SLASH;
+
        if (!intern->file_name) {
                switch (intern->type) {
                case SPL_FS_INFO:
@@ -184,7 +186,7 @@
                case SPL_FS_DIR:
                        intern->file_name_len = spprintf(&intern->file_name, 0, 
"%s%c%s",
                                                         
spl_filesystem_object_get_path(intern, NULL TSRMLS_CC),
-                                                        DEFAULT_SLASH, 
intern->u.dir.entry.d_name);
+                                                        slash, 
intern->u.dir.entry.d_name);
                        break;
                }
        }
@@ -615,6 +617,9 @@
        if (ctor_flags & SPL_FILE_DIR_SKIPDOTS) {
                flags |= SPL_FILE_DIR_SKIPDOTS;
        }
+       if (ctor_flags & SPL_FILE_DIR_UNIXPATHS) {
+               flags |= SPL_FILE_DIR_UNIXPATHS;
+       }
        if (parsed == FAILURE) {
                php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
                return;
@@ -1244,6 +1249,7 @@
        zval zpath, zflags;
        spl_filesystem_object *intern = 
(spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
        spl_filesystem_object *subdir;
+       char slash = intern->flags & SPL_FILE_DIR_UNIXPATHS ? '/' : 
DEFAULT_SLASH;
        
        spl_filesystem_object_get_file_name(intern TSRMLS_CC);
 
@@ -1257,7 +1263,7 @@
        subdir = 
(spl_filesystem_object*)zend_object_store_get_object(return_value TSRMLS_CC);
        if (subdir) {
                if (intern->u.dir.sub_path && intern->u.dir.sub_path[0]) {
-                       subdir->u.dir.sub_path_len = 
spprintf(&subdir->u.dir.sub_path, 0, "%s%c%s", intern->u.dir.sub_path, 
DEFAULT_SLASH, intern->u.dir.entry.d_name);
+                       subdir->u.dir.sub_path_len = 
spprintf(&subdir->u.dir.sub_path, 0, "%s%c%s", intern->u.dir.sub_path, slash, 
intern->u.dir.entry.d_name);
                } else {
                        subdir->u.dir.sub_path_len = 
strlen(intern->u.dir.entry.d_name);
                        subdir->u.dir.sub_path = 
estrndup(intern->u.dir.entry.d_name, subdir->u.dir.sub_path_len);
@@ -1290,9 +1296,10 @@
        spl_filesystem_object *intern = 
(spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
        char *sub_name;
        int len;
+       char slash = intern->flags & SPL_FILE_DIR_UNIXPATHS ? '/' : 
DEFAULT_SLASH;
 
        if (intern->u.dir.sub_path) {
-               len = spprintf(&sub_name, 0, "%s%c%s", intern->u.dir.sub_path, 
DEFAULT_SLASH, intern->u.dir.entry.d_name);
+               len = spprintf(&sub_name, 0, "%s%c%s", intern->u.dir.sub_path, 
slash, intern->u.dir.entry.d_name);
                RETURN_STRINGL(sub_name, len, 0);
        } else {
                RETURN_STRING(intern->u.dir.entry.d_name, 1);
@@ -2624,6 +2631,7 @@
        REGISTER_SPL_CLASS_CONST_LONG(FilesystemIterator, "KEY_AS_FILENAME",    
 SPL_FILE_DIR_KEY_AS_FILENAME);
        REGISTER_SPL_CLASS_CONST_LONG(FilesystemIterator, 
"NEW_CURRENT_AND_KEY", 
SPL_FILE_DIR_KEY_AS_FILENAME|SPL_FILE_DIR_CURRENT_AS_FILEINFO);
        REGISTER_SPL_CLASS_CONST_LONG(FilesystemIterator, "SKIP_DOTS",          
 SPL_FILE_DIR_SKIPDOTS);
+       REGISTER_SPL_CLASS_CONST_LONG(FilesystemIterator, "UNIX_PATHS",         
 SPL_FILE_DIR_UNIXPATHS);
 
        spl_ce_FilesystemIterator->get_iterator = 
spl_filesystem_tree_get_iterator;
 
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_directory.h?r1=1.12.2.5.2.4.2.11&r2=1.12.2.5.2.4.2.12&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.11 
php-src/ext/spl/spl_directory.h:1.12.2.5.2.4.2.12
--- php-src/ext/spl/spl_directory.h:1.12.2.5.2.4.2.11   Sat Jul 19 11:20:18 2008
+++ php-src/ext/spl/spl_directory.h     Thu Jul 24 08:55:52 2008
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: spl_directory.h,v 1.12.2.5.2.4.2.11 2008/07/19 11:20:18 colder Exp $ */
+/* $Id: spl_directory.h,v 1.12.2.5.2.4.2.12 2008/07/24 08:55:52 sfox Exp $ */
 
 #ifndef SPL_DIRECTORY_H
 #define SPL_DIRECTORY_H
@@ -133,6 +133,7 @@
 #define SPL_FILE_DIR_KEY(intern,mode)      
((intern->flags&SPL_FILE_DIR_KEY_MODE_MASK)==mode)
 
 #define SPL_FILE_DIR_SKIPDOTS              0x00001000 /* Tells whether it 
should skip dots or not */
+#define SPL_FILE_DIR_UNIXPATHS             0x00002000 /* Whether to unixify 
path separators */
 
 #endif /* SPL_DIRECTORY_H */
 



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

Reply via email to