summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre Joye <pajoye@php.net>2008-08-11 13:11:31 +0000
committerPierre Joye <pajoye@php.net>2008-08-11 13:11:31 +0000
commit7023ed85d7b2645111d5ac8c33a3ac428eff58db (patch)
treef17609563313b95b57f2e0c4e638433472f39448
parente82568d9e4af779ca10619a3cd5d2f0968a903b5 (diff)
downloadphp-git-7023ed85d7b2645111d5ac8c33a3ac428eff58db.tar.gz
- [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
-rw-r--r--ext/standard/file.c16
-rw-r--r--ext/standard/tests/file/copy_variation4-win32.phptbin4277 -> 0 bytes
-rw-r--r--ext/standard/tests/file/copy_variation4.phptbin4549 -> 4654 bytes
3 files changed, 14 insertions, 2 deletions
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
--- a/ext/standard/tests/file/copy_variation4-win32.phpt
+++ /dev/null
Binary files differ
diff --git a/ext/standard/tests/file/copy_variation4.phpt b/ext/standard/tests/file/copy_variation4.phpt
index 684384fe5a..48386743f3 100644
--- a/ext/standard/tests/file/copy_variation4.phpt
+++ b/ext/standard/tests/file/copy_variation4.phpt
Binary files differ