pajoye Wed Jun 3 08:07:30 2009 UTC Modified files: /php-src/ext/standard link_win32.c /php-src/ext/standard/tests/file link_win32.phpt Log: - MFB: fix parameter order and return value check in windows (Venkat Raman Don, Pierre)' link http://cvs.php.net/viewvc.cgi/php-src/ext/standard/link_win32.c?r1=1.4&r2=1.5&diff_format=u Index: php-src/ext/standard/link_win32.c diff -u php-src/ext/standard/link_win32.c:1.4 php-src/ext/standard/link_win32.c:1.5 --- php-src/ext/standard/link_win32.c:1.4 Tue Mar 10 23:39:40 2009 +++ php-src/ext/standard/link_win32.c Wed Jun 3 08:07:29 2009 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: link_win32.c,v 1.4 2009/03/10 23:39:40 helly Exp $ */ +/* $Id: link_win32.c,v 1.5 2009/06/03 08:07:29 pajoye Exp $ */ #ifdef PHP_WIN32 #include "php.h" @@ -230,7 +230,9 @@ 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; } @@ -259,7 +261,8 @@ #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; } http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/link_win32.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/file/link_win32.phpt diff -u /dev/null php-src/ext/standard/tests/file/link_win32.phpt:1.2 --- /dev/null Wed Jun 3 08:07:30 2009 +++ php-src/ext/standard/tests/file/link_win32.phpt Wed Jun 3 08:07:30 2009 @@ -0,0 +1,26 @@ +--TEST-- +bug #<bugid> (link not working properly on Windows) +--CREDITS-- +Venkat Raman Don +--SKIPIF-- +<?php +if(substr(PHP_OS, 0, 3) != 'WIN' ) { + die('skip windows only test'); +} +?> +--FILE-- +<?php +$filename = __DIR__ . '\\a.php'; +$content = '<?php echo "Dummy Content.\n" ?>'; +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)
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php