]> granicus.if.org Git - php/commitdiff
- MFB: fix parameter order and return value check in windows (Venkat Raman Don, Pierr...
authorPierre Joye <pajoye@php.net>
Wed, 3 Jun 2009 08:07:30 +0000 (08:07 +0000)
committerPierre Joye <pajoye@php.net>
Wed, 3 Jun 2009 08:07:30 +0000 (08:07 +0000)
ext/standard/link_win32.c
ext/standard/tests/file/link_win32.phpt [new file with mode: 0644]

index aa4c870a244dcd85aaed1a70e984ef230721bd1f..12aa3937158ae028842a32539cbcf05d929b1283 100644 (file)
@@ -230,7 +230,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;
        }
 
@@ -259,7 +261,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 (file)
index 0000000..f2f9324
--- /dev/null
@@ -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)