cvs: php-src(PHP_5_2) /ext/spl spl_directory.c /ext/spl/tests fileobject_003.phpt

From: Date: Sat, 15 Jul 2006 13:01:59 +0000
Subject: cvs: php-src(PHP_5_2) /ext/spl spl_directory.c /ext/spl/tests fileobject_003.phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-39255@lists.php.net to get a copy of this message
helly Sat Jul 15 13:01:59 2006 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/spl spl_directory.c /php-src/ext/spl/tests fileobject_003.phpt Log: - MFH Fix issue with SplFileObject and directories http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_directory.c?r1=1.45.2.27.2.2&r2=1.45.2.27.2.3&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.2 php-src/ext/spl/spl_directory.c:1.45.2.27.2.3 --- php-src/ext/spl/spl_directory.c:1.45.2.27.2.2 Mon Jul 10 15:47:58 2006 +++ php-src/ext/spl/spl_directory.c Sat Jul 15 13:01:59 2006 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: spl_directory.c,v 1.45.2.27.2.2 2006/07/10 15:47:58 dmitry Exp $ */ +/* $Id: spl_directory.c,v 1.45.2.27.2.3 2006/07/15 13:01:59 helly Exp $ */ #ifdef HAVE_CONFIG_H # include "config.h" @@ -205,9 +205,9 @@ intern->u.file.context = php_stream_context_from_zval(intern->u.file.zcontext, 0); intern->u.file.stream = php_stream_open_wrapper_ex(intern->file_name, intern->u.file.open_mode, (use_include_path ? USE_PATH : 0) | ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL, intern->u.file.context); - if (intern->u.file.stream == NULL) { + if (!intern->file_name_len || !intern->u.file.stream) { if (!EG(exception)) { - zend_throw_exception_ex(spl_ce_RuntimeException, 0 TSRMLS_CC, "Cannot open file %s", intern->file_name); + zend_throw_exception_ex(spl_ce_RuntimeException, 0 TSRMLS_CC, "Cannot open file '%s'", intern->file_name_len ? intern->file_name : ""); } intern->file_name = NULL; /* until here it is not a copy */ intern->u.file.open_mode = NULL; @@ -218,6 +218,14 @@ zend_list_addref(Z_RESVAL_P(intern->u.file.zcontext)); } + if (intern->file_name[intern->file_name_len-1] == '/' +#if defined(PHP_WIN32) || defined(NETWARE) + ||intern->file_name[intern->file_name_len-1] == '\\' +#endif + ) { + intern->file_name_len--; + } + intern->file_name = estrndup(intern->file_name, intern->file_name_len); intern->u.file.open_mode = estrndup(intern->u.file.open_mode, intern->u.file.open_mode_len); http://cvs.php.net/viewvc.cgi/php-src/ext/spl/tests/fileobject_003.phpt?r1=1.1.2.2&r2=1.1.2.3&diff_format=u Index: php-src/ext/spl/tests/fileobject_003.phpt diff -u php-src/ext/spl/tests/fileobject_003.phpt:1.1.2.2 php-src/ext/spl/tests/fileobject_003.phpt:1.1.2.3 --- php-src/ext/spl/tests/fileobject_003.phpt:1.1.2.2 Sat Jul 8 12:25:57 2006 +++ php-src/ext/spl/tests/fileobject_003.phpt Sat Jul 15 13:01:59 2006 @@ -5,7 +5,7 @@ --FILE-- <?php -function test($name) +function test($name, $lc, $lp) { static $i = 0; echo "===$i===\n"; @@ -19,10 +19,23 @@ var_dump($o === $c); var_dump($o == $c); var_dump($o->getPathname() == $c->getPathname()); + + $f = new SplFileObject($name); + var_dump($name); + var_dump($f->getPathName()); + $l = substr($f->getPathName(), -1); + var_dump($l != '/' && $l != '\\' && $l == $lc); + var_dump($f->getFileName()); + $l = substr($f->getFileName(), -1); + var_dump($l != '/' && $l != '\\' && $l == $lc); + var_dump($f->getPath()); + $l = substr($f->getPath(), -1); + var_dump($l != '/' && $l != '\\' && $l == $lp); } -test(dirname(__FILE__) . '/' . 'fileobject_001a.txt'); -test(dirname(__FILE__) . '/'); +test(dirname(__FILE__) . '/' . 'fileobject_001a.txt', 't', substr(dirname(__FILE__),-1)); +test(dirname(__FILE__) . '/', substr(dirname(__FILE__),-1), 'l'); +test(dirname(__FILE__), substr(dirname(__FILE__),-1), 'l'); ?> ===DONE=== @@ -36,6 +49,13 @@ bool(false) bool(true) bool(true) +string(%d) "%sfileobject_001a.txt" +string(%d) "%sfileobject_001a.txt" +bool(true) +string(%d) "%sfileobject_001a.txt" +bool(true) +string(%d) "%stests" +bool(true) ===1=== object(SplFileInfo)#%d (0) { } @@ -44,4 +64,26 @@ bool(false) bool(true) bool(true) +string(%d) "%stests/" +string(%d) "%stests" +bool(true) +string(%d) "%stests" +bool(true) +string(%d) "%sspl" +bool(true) +===2=== +object(SplFileInfo)#1 (0) { +} +object(SplFileInfo)#2 (0) { +} +bool(false) +bool(true) +bool(true) +string(%d) "%stests" +string(%d) "%stests" +bool(true) +string(%d) "%stests" +bool(true) +string(%d) "%sspl" +bool(true) ===DONE===

« previous php.cvs (#39255) next »