From: Ilia Alshanetsky Date: Sun, 12 Aug 2007 17:09:59 +0000 (+0000) Subject: Fixed copy test as well as the directory check inside copy() function X-Git-Tag: php-5.2.4RC2~27 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fb8e3abe88ed06d4cd307ecd0b10018f545b02e5;p=php Fixed copy test as well as the directory check inside copy() function --- diff --git a/ext/standard/file.c b/ext/standard/file.c index 594a5ec3f8..d0ae78fb54 100644 --- a/ext/standard/file.c +++ b/ext/standard/file.c @@ -1765,13 +1765,13 @@ PHPAPI int php_copy_file_ex(char *src, char *dest, int src_chk TSRMLS_DC) default: /* failed to stat file, does not exist? */ return ret; } - if (php_stream_stat_path_ex(dest, PHP_STREAM_URL_STAT_QUIET, &dest_s, NULL) != 0) { - goto safe_to_copy; - } if (S_ISDIR(src_s.sb.st_mode)) { 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; + } if (!src_s.sb.st_ino || !dest_s.sb.st_ino) { goto no_stat; } diff --git a/ext/standard/tests/file/copy_variation12.phpt b/ext/standard/tests/file/copy_variation12.phpt index 32a45311a2..e5a415e9d7 100644 --- a/ext/standard/tests/file/copy_variation12.phpt +++ b/ext/standard/tests/file/copy_variation12.phpt @@ -41,8 +41,12 @@ rmdir(dirname(__FILE__)."/copy_variation12"); --EXPECTF-- *** Test copy() function: Trying to create a copy of an existing dir *** + +Warning: copy(): The first argument to copy() function cannot be a directory in %s/copy_variation12.php on line %d bool(false) bool(false) int(4096) -int(0) + +Warning: filesize(): stat failed for %s/copy_copy_variation12 in %s/copy_variation12.php on line %d +bool(false) *** Done ***