From 7023ed85d7b2645111d5ac8c33a3ac428eff58db Mon Sep 17 00:00:00 2001 From: Pierre Joye Date: Mon, 11 Aug 2008 13:11:31 +0000 Subject: - [DOC] MFH: 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 --- ext/standard/file.c | 16 ++++++++++++++-- ext/standard/tests/file/copy_variation4-win32.phpt | Bin 4277 -> 0 bytes ext/standard/tests/file/copy_variation4.phpt | Bin 4549 -> 4654 bytes 3 files changed, 14 insertions(+), 2 deletions(-) delete mode 100644 ext/standard/tests/file/copy_variation4-win32.phpt diff --git a/ext/standard/file.c b/ext/standard/file.c index c8178e0581..6ad1b6c02e 100644 --- a/ext/standard/file.c +++ b/ext/standard/file.c @@ -1731,8 +1731,20 @@ 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; } - if (php_stream_stat_path_ex(dest, PHP_STREAM_URL_STAT_QUIET, &dest_s, NULL) != 0) { - goto safe_to_copy; + + 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 (!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 -- cgit v1.2.1