From: Pierre Joye Date: Wed, 3 Jun 2009 07:56:53 +0000 (+0000) Subject: - fix parameter order and return value check in windows (Venkat Raman Don, Pierre... X-Git-Tag: php-5.3.0RC3~53 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2f6f336205e19258652115e95c1952ced12b8e71;p=php - fix parameter order and return value check in windows (Venkat Raman Don, Pierre)' link --- diff --git a/ext/standard/link_win32.c b/ext/standard/link_win32.c index 841da3ef38..b5caba36a3 100644 --- a/ext/standard/link_win32.c +++ b/ext/standard/link_win32.c @@ -231,7 +231,9 @@ PHP_FUNCTION(link) char source_p[MAXPATHLEN]; char dest_p[MAXPATHLEN]; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &topath, &topath_len, &frompath, &frompath_len) == FAILURE) { + /*First argument to link function is the target and hence should go to frompath + Second argument to link function is the link itself and hence should go to topath */ + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &frompath, &frompath_len, &topath, &topath_len) == FAILURE) { return; } @@ -260,7 +262,8 @@ PHP_FUNCTION(link) #else ret = CreateHardLinkA(dest_p, source_p, NULL); #endif - if (ret == -1) { + + if (ret == 0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", strerror(errno)); RETURN_FALSE; } diff --git a/ext/standard/tests/file/link_win32.phpt b/ext/standard/tests/file/link_win32.phpt new file mode 100644 index 0000000000..f2f9324f68 --- /dev/null +++ b/ext/standard/tests/file/link_win32.phpt @@ -0,0 +1,26 @@ +--TEST-- +bug # (link not working properly on Windows) +--CREDITS-- +Venkat Raman Don +--SKIPIF-- + +--FILE-- +'; +file_put_contents($filename, $content); +$linkname = __DIR__ . '\\a_link.php'; +link("$filename", "$linkname"); +var_dump(file_exists("$linkname")); +$linkcontent = file_get_contents($linkname); +var_dump($content == $linkcontent); +unlink($filename); +unlink($linkname); +?> +--EXPECT-- +bool(true) +bool(true)