]> granicus.if.org Git - php/commitdiff
- [DOC] detect if dest is a dir (if the given stream layer supports stat)
authorPierre Joye <pajoye@php.net>
Mon, 11 Aug 2008 13:09:01 +0000 (13:09 +0000)
committerPierre Joye <pajoye@php.net>
Mon, 11 Aug 2008 13:09:01 +0000 (13:09 +0000)
  and fails
 . remove win32 specific test. The errors are not the same

ext/standard/file.c
ext/standard/tests/file/copy_variation4-win32.phpt [deleted file]
ext/standard/tests/file/copy_variation4.phpt

index 4a7bde1ba3c471ebb70beda092e2faeedb3ae921..82e18dd7e75584ea8f0b4b2a4d23d69fc1f18ea5 100644 (file)
@@ -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 (file)
index ae2a1ed..0000000
Binary files a/ext/standard/tests/file/copy_variation4-win32.phpt and /dev/null differ
index 684384fe5a6ab032a66aa0edc570b2412f102f5e..48386743f325e3cfedaa7712443a6af249aa9593 100644 (file)
Binary files a/ext/standard/tests/file/copy_variation4.phpt and b/ext/standard/tests/file/copy_variation4.phpt differ