sfox Thu Jul 24 08:52:24 2008 UTC Modified files: /php-src/ext/spl spl_directory.c spl_directory.h Log: - Introduce SPL_FILE_DIR_UNIXPATHS. http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_directory.c?r1=1.161&r2=1.162&diff_format=u Index: php-src/ext/spl/spl_directory.c diff -u php-src/ext/spl/spl_directory.c:1.161 php-src/ext/spl/spl_directory.c:1.162 --- php-src/ext/spl/spl_directory.c:1.161 Wed Jul 23 06:12:44 2008 +++ php-src/ext/spl/spl_directory.c Thu Jul 24 08:52:24 2008 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: spl_directory.c,v 1.161 2008/07/23 06:12:44 helly Exp $ */ +/* $Id: spl_directory.c,v 1.162 2008/07/24 08:52:24 sfox Exp $ */ #ifdef HAVE_CONFIG_H # include "config.h" @@ -185,6 +185,8 @@ { zstr path; zend_uchar path_type; + char slash = intern->flags & SPL_FILE_DIR_UNIXPATHS ? '/' : DEFAULT_SLASH; + if (!intern->file_name.v) { switch (intern->type) { case SPL_FS_INFO: @@ -195,7 +197,7 @@ path = spl_filesystem_object_get_path(intern, NULL, &path_type TSRMLS_CC); intern->file_name_len = zspprintf(path_type, &intern->file_name, 0, "%R%c%s", path_type, path, - DEFAULT_SLASH, intern->u.dir.entry.d_name); + slash, intern->u.dir.entry.d_name); intern->file_name_type = path_type; break; } @@ -684,6 +686,10 @@ 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; @@ -1372,6 +1378,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); @@ -1388,7 +1395,7 @@ if (subdir) { if (intern->u.dir.sub_path.v && intern->u.dir.sub_path_len > 1) { subdir->u.dir.sub_path_type = intern->u.dir.sub_path_type; - subdir->u.dir.sub_path_len = zspprintf(intern->u.dir.sub_path_type, &subdir->u.dir.sub_path, 0, "%R%c%s", intern->u.dir.sub_path_type, intern->u.dir.sub_path, DEFAULT_SLASH, intern->u.dir.entry.d_name); + subdir->u.dir.sub_path_len = zspprintf(intern->u.dir.sub_path_type, &subdir->u.dir.sub_path, 0, "%R%c%s", intern->u.dir.sub_path_type, 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_type = IS_STRING; @@ -1422,9 +1429,10 @@ spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC); zstr sub_name; int sub_len; + char slash = intern->flags & SPL_FILE_DIR_UNIXPATHS ? '/' : DEFAULT_SLASH; if (intern->u.dir.sub_path.v) { - sub_len = zspprintf(intern->u.dir.sub_path_type, &sub_name, 0, "%R%c%s", intern->u.dir.sub_path_type, intern->u.dir.sub_path, DEFAULT_SLASH, intern->u.dir.entry.d_name); + sub_len = zspprintf(intern->u.dir.sub_path_type, &sub_name, 0, "%R%c%s", intern->u.dir.sub_path_type, intern->u.dir.sub_path, slash, intern->u.dir.entry.d_name); RETURN_ZSTRL(intern->u.dir.sub_path_type, sub_name, sub_len, 0); } else { RETURN_RT_STRING(intern->u.dir.entry.d_name, ZSTR_DUPLICATE); @@ -2770,6 +2778,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.45&r2=1.46&diff_format=u Index: php-src/ext/spl/spl_directory.h diff -u php-src/ext/spl/spl_directory.h:1.45 php-src/ext/spl/spl_directory.h:1.46 --- php-src/ext/spl/spl_directory.h:1.45 Sat Jul 19 11:20:04 2008 +++ php-src/ext/spl/spl_directory.h Thu Jul 24 08:52:24 2008 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: spl_directory.h,v 1.45 2008/07/19 11:20:04 colder Exp $ */ +/* $Id: spl_directory.h,v 1.46 2008/07/24 08:52:24 sfox Exp $ */ #ifndef SPL_DIRECTORY_H #define SPL_DIRECTORY_H @@ -136,6 +136,7 @@ #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