From: Pierre Joye Date: Mon, 11 Aug 2008 13:09:01 +0000 (+0000) Subject: - [DOC] detect if dest is a dir (if the given stream layer supports stat) X-Git-Tag: BEFORE_HEAD_NS_CHANGE~777 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=94b661a37f885df533a3521e6d03d11aa3d0fc8c;p=php - [DOC] detect if dest is a dir (if the given stream layer supports stat) and fails . remove win32 specific test. The errors are not the same --- diff --git a/ext/standard/file.c b/ext/standard/file.c index 4a7bde1ba3..82e18dd7e7 100644 --- a/ext/standard/file.c +++ b/ext/standard/file.c @@ -1892,9 +1892,26 @@ PHPAPI int php_copy_file_ex(char *src, char *dest, int src_chk TSRMLS_DC) php_error_docref(NULL TSRMLS_CC, E_WARNING, "The first argument to copy() function cannot be a directory"); return FAILURE; } + + switch (php_stream_stat_path_ex(dest, PHP_STREAM_URL_STAT_QUIET, &dest_s, NULL)) { + case -1: + /* non-statable stream */ + goto safe_to_copy; + break; + case 0: + break; + default: /* failed to stat file, does not exist? */ + return ret; + } + if (S_ISDIR(dest_s.sb.st_mode)) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "The second argument to copy() function cannot be a directory"); + return FAILURE; + } + /* if (php_stream_stat_path_ex(dest, PHP_STREAM_URL_STAT_QUIET, &dest_s, NULL) != 0) { goto safe_to_copy; } +*/ if (!src_s.sb.st_ino || !dest_s.sb.st_ino) { goto no_stat; } diff --git a/ext/standard/tests/file/copy_variation4-win32.phpt b/ext/standard/tests/file/copy_variation4-win32.phpt deleted file mode 100644 index ae2a1ed527..0000000000 Binary files a/ext/standard/tests/file/copy_variation4-win32.phpt and /dev/null differ diff --git a/ext/standard/tests/file/copy_variation4.phpt b/ext/standard/tests/file/copy_variation4.phpt index 684384fe5a..48386743f3 100644 Binary files a/ext/standard/tests/file/copy_variation4.phpt and b/ext/standard/tests/file/copy_variation4.phpt differ