pajoye Fri, 10 Sep 2010 14:17:40 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=303258
Log: - Implement bug #51804, splFileInfo::getLinkTarget() on Windows Bug: http://bugs.php.net/51804 (Assigned) SplFileInfo::getLinkTarget() Fails. Changed paths: U php/php-src/branches/PHP_5_3/NEWS U php/php-src/branches/PHP_5_3/ext/spl/spl_directory.c U php/php-src/trunk/ext/spl/spl_directory.c Modified: php/php-src/branches/PHP_5_3/NEWS =================================================================== --- php/php-src/branches/PHP_5_3/NEWS 2010-09-10 14:02:19 UTC (rev 303257) +++ php/php-src/branches/PHP_5_3/NEWS 2010-09-10 14:17:40 UTC (rev 303258) @@ -10,6 +10,8 @@ (Andrey) - Improved support for is_link and related functions on Windows. (Pierre) +- Implemented FR #51804, SplFileInfo::getLinkTarget on Windows. (Pierre) + - Fixed symbolic resolution support when the target is a DFS share. (Pierre) - Fixed MOPS-2010-24, fix string validation. (CVE-2010-2950). (Pierre) - Changed deprecated ini options on startup from E_WARNING to E_DEPRECATED. Modified: php/php-src/branches/PHP_5_3/ext/spl/spl_directory.c =================================================================== --- php/php-src/branches/PHP_5_3/ext/spl/spl_directory.c 2010-09-10 14:02:19 UTC (rev 303257) +++ php/php-src/branches/PHP_5_3/ext/spl/spl_directory.c 2010-09-10 14:17:40 UTC (rev 303258) @@ -1050,8 +1050,21 @@ zend_replace_error_handling(EH_THROW, spl_ce_RuntimeException, &error_handling TSRMLS_CC); -#ifdef HAVE_SYMLINK - ret = readlink(intern->file_name, buff, MAXPATHLEN-1); +#if defined(PHP_WIN32) || HAVE_SYMLINK + if (!IS_ABSOLUTE_PATH(intern->file_name, intern->file_name_len)) { + char expanded_path[MAXPATHLEN]; + + /* TODO: Fix expand_filepath to do not resolve links but only expand the path + avoiding double two resolution attempts + (Pierre) */ + if (!expand_filepath(intern->file_name, expanded_path TSRMLS_CC)) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "No such file or directory"); + RETURN_FALSE; + } + ret = php_sys_readlink(expanded_path, buff, MAXPATHLEN - 1); + } else { + ret = php_sys_readlink(intern->file_name, buff, MAXPATHLEN-1); + } #else ret = -1; /* always fail if not implemented */ #endif Modified: php/php-src/trunk/ext/spl/spl_directory.c =================================================================== --- php/php-src/trunk/ext/spl/spl_directory.c 2010-09-10 14:02:19 UTC (rev 303257) +++ php/php-src/trunk/ext/spl/spl_directory.c 2010-09-10 14:17:40 UTC (rev 303258) @@ -1053,8 +1053,20 @@ zend_replace_error_handling(EH_THROW, spl_ce_RuntimeException, &error_handling TSRMLS_CC); -#ifdef HAVE_SYMLINK - ret = readlink(intern->file_name, buff, MAXPATHLEN-1); +#if defined(PHP_WIN32) || HAVE_SYMLINK + if (!IS_ABSOLUTE_PATH(intern->file_name, intern->file_name_len)) { + char expanded_path[MAXPATHLEN]; + + /* TODO: Fix expand_filepath to do not resolve links but only expand the path + (Pierre) */ + if (!expand_filepath(intern->file_name, expanded_path TSRMLS_CC)) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "No such file or directory"); + RETURN_FALSE; + } + ret = php_sys_readlink(expanded_path, buff, MAXPATHLEN - 1); + } else { + ret = php_sys_readlink(intern->file_name, buff, MAXPATHLEN-1); + } #else ret = -1; /* always fail if not implemented */ #endif
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php