From 94b661a37f885df533a3521e6d03d11aa3d0fc8c Mon Sep 17 00:00:00 2001 From: Pierre Joye Date: Mon, 11 Aug 2008 13:09:01 +0000 Subject: [PATCH] - [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 --- ext/standard/file.c | 17 +++++++++++++++++ .../tests/file/copy_variation4-win32.phpt | Bin 4277 -> 0 bytes ext/standard/tests/file/copy_variation4.phpt | Bin 4549 -> 4654 bytes 3 files changed, 17 insertions(+) delete mode 100644 ext/standard/tests/file/copy_variation4-win32.phpt 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 ae2a1ed5275c435011ac6f27eec2e0c24c140596..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4277 zcmeHJYj4{&6y0b2iaQ}0q||caJ~kj-S`?{+8uKzEc9DGuATTmj3sFdcq~>|U{`>AF z^{`{v3o@)gv3{{kNxYA9&OKBV&4$xi6nQhQ4J5Ky1tFxRNK7WhDU_Oh;_w?&8KWB- zBADZgnXpSpvz&uq_gn}3zA!7$MrGnt4@8;g8oq;DDRUiqQ8fK&G#OoBo*&;9i^9v& zK$o}pb};!ciGP{);G_pHLiqL!{Oi%BA9?`uj0e8H%L=$E1xS&v@CU9lF_%m2hp)Z2 zZ!qx1XgqAf9v{I(Nh8gw;HNgZZ3%*^FgVb%R0;1jYw89t7682GI#F5S8vmKyaShCE zmnoP9cip-GV59}2Pa6TQxG5E)GrRgYq#|{hBwTBd3NGG_r}kdTvbY5&moMfW#9Q3_CePt`*5Bh-2b2j**cAt&-TjLr?IXc0=DkCZ)!WE?@S| zebK~RU~{O;Ge~8@MX(vD2mX@8lP*;kK^16iDc$>KI z(kz*Hhi>Wi=D2LR-u_I@q_p=+@SYB z`YlE^yj`-Tw+P0j-by2N#hWNS|B8}hbuUUUzF3sL`J7^U`NhKYIZ=A`6{Sav-1kpI msj}j2|6cRn{fENieR}ZkRns1M?ZNfK|EP2N`lvs0yuShM{B9xu diff --git a/ext/standard/tests/file/copy_variation4.phpt b/ext/standard/tests/file/copy_variation4.phpt index 684384fe5a6ab032a66aa0edc570b2412f102f5e..48386743f325e3cfedaa7712443a6af249aa9593 100644 GIT binary patch delta 305 zcmX@AyiR392B)#6l|o2HszPyUa(-TlLSj*RX>Mv>i9$)fLUMjVrG}bFOck@FoTSjs;0xd0?ypHD#nR@R}F6Sf5!646WzQq5T F5dh&Fa6bS5 delta 196 zcmZ3da#VRk2B(~Av8I(mT4H8SYKlThzCwOMYMw%INl|KIu9bpk@#HtW_a|3z#Sx?I c6*m#eiYCA1IYYp-&2M;Z840P0;lIQL04