[PHP-CVS] cvs: php-src /ext/standard link_win32.c

2009-06-16 Thread Pierre-Alain Joye
pajoye  Tue Jun 16 16:53:56 2009 UTC

  Modified files:  
/php-src/ext/standard   link_win32.c 
  Log:
  - MF53: fix readlink in TS SAPI
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/link_win32.c?r1=1.5&r2=1.6&diff_format=u
Index: php-src/ext/standard/link_win32.c
diff -u php-src/ext/standard/link_win32.c:1.5 
php-src/ext/standard/link_win32.c:1.6
--- php-src/ext/standard/link_win32.c:1.5   Wed Jun  3 08:07:29 2009
+++ php-src/ext/standard/link_win32.c   Tue Jun 16 16:53:56 2009
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: link_win32.c,v 1.5 2009/06/03 08:07:29 pajoye Exp $ */
+/* $Id: link_win32.c,v 1.6 2009/06/16 16:53:56 pajoye Exp $ */
 #ifdef PHP_WIN32
 
 #include "php.h"
@@ -62,6 +62,7 @@
char *link;
int link_len;
TCHAR Path[MAXPATHLEN];
+   char path_resolved[MAXPATHLEN];
HANDLE hFile;
DWORD dwRet;
 
@@ -88,14 +89,17 @@
if (OPENBASEDIR_CHECKPATH(link)) {
RETURN_FALSE;
}
-
-   hFile = CreateFile(link,  // file to open
-   
 GENERIC_READ,  // open for reading
-   
 FILE_SHARE_READ,   // share for reading
-   
 NULL,  // default security
-   
 OPEN_EXISTING, // existing file only
-   
 FILE_FLAG_BACKUP_SEMANTICS, // normal file
-   
 NULL); // no attr. template
+   if (!expand_filepath(link, path_resolved TSRMLS_CC)) {
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, "No such file or 
directory");
+   RETURN_FALSE;
+   }
+   hFile = CreateFile(path_resolved,  // file to open
+GENERIC_READ,  // open for reading
+FILE_SHARE_READ,   // share for reading
+NULL,  // default security
+OPEN_EXISTING, // existing file only
+FILE_FLAG_BACKUP_SEMANTICS, // normal file
+NULL); // no attr. template
 
if( hFile == INVALID_HANDLE_VALUE) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not 
open file (error %d)", GetLastError());



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/standard link_win32.c /ext/standard/tests/file link_win32.phpt

2009-06-03 Thread Pierre-Alain Joye
pajoye  Wed Jun  3 08:07:30 2009 UTC

  Modified files:  
/php-src/ext/standard   link_win32.c 
/php-src/ext/standard/tests/filelink_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 # (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)



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/standard link_win32.c

2009-01-16 Thread Pierre-Alain Joye
pajoye  Fri Jan 16 15:35:50 2009 UTC

  Modified files:  
/php-src/ext/standard   link_win32.c 
  Log:
  - MFB: fix VC6 build
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/link_win32.c?r1=1.2&r2=1.3&diff_format=u
Index: php-src/ext/standard/link_win32.c
diff -u php-src/ext/standard/link_win32.c:1.2 
php-src/ext/standard/link_win32.c:1.3
--- php-src/ext/standard/link_win32.c:1.2   Fri Jan 16 10:04:29 2009
+++ php-src/ext/standard/link_win32.c   Fri Jan 16 15:35:50 2009
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: link_win32.c,v 1.2 2009/01/16 10:04:29 pajoye Exp $ */
+/* $Id: link_win32.c,v 1.3 2009/01/16 15:35:50 pajoye Exp $ */
 #ifdef PHP_WIN32
 
 #include "php.h"
@@ -50,6 +50,10 @@
 - this file is then useless and we have a portable link API
 */
 
+#ifndef VOLUME_NAME_NT
+#define VOLUME_NAME_NT 0x2
+#endif
+
 /* {{{ proto string readlink(string filename)
Return the target of a symbolic link */
 PHP_FUNCTION(readlink)
@@ -149,7 +153,7 @@
size_t len;
DWORD attr;
HINSTANCE kernel32;
-   typedef BOOLEAN (WINAPI *csla_func)( __in LPCSTR, __in LPCSTR, __in 
DWORD);
+   typedef BOOLEAN (WINAPI *csla_func)(LPCSTR, LPCSTR, DWORD);
csla_func pCreateSymbolicLinkA;
 
kernel32 = LoadLibrary("kernel32.dll");



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php