pajoye          Thu Sep  4 08:05:27 2008 UTC

  Added files:                 (Branch: PHP_5_3)
    /php-src/ext/standard/tests/file    bug45985.phpt 

  Modified files:              
    /TSRM       tsrm_virtual_cwd.c 
  Log:
  - MFH: #45985, touch on opened file raises a warning
  
http://cvs.php.net/viewvc.cgi/TSRM/tsrm_virtual_cwd.c?r1=1.74.2.9.2.35.2.13&r2=1.74.2.9.2.35.2.14&diff_format=u
Index: TSRM/tsrm_virtual_cwd.c
diff -u TSRM/tsrm_virtual_cwd.c:1.74.2.9.2.35.2.13 
TSRM/tsrm_virtual_cwd.c:1.74.2.9.2.35.2.14
--- TSRM/tsrm_virtual_cwd.c:1.74.2.9.2.35.2.13  Tue Aug 19 15:00:20 2008
+++ TSRM/tsrm_virtual_cwd.c     Thu Sep  4 08:05:27 2008
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: tsrm_virtual_cwd.c,v 1.74.2.9.2.35.2.13 2008/08/19 15:00:20 dmitry Exp 
$ */
+/* $Id: tsrm_virtual_cwd.c,v 1.74.2.9.2.35.2.14 2008/09/04 08:05:27 pajoye Exp 
$ */
 
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -818,7 +818,6 @@
        }
 #endif
 
-
        add_slash = (use_realpath != CWD_REALPATH) && path_length > 0 && 
IS_SLASH(resolved_path[path_length-1]);
        t = CWDG(realpath_cache_ttl) ? 0 : -1;
        path_length = tsrm_realpath_r(resolved_path, start, path_length, &ll, 
&t, use_realpath, 0, NULL TSRMLS_CC);
@@ -1033,8 +1032,14 @@
        BOOL f;
        HANDLE hFile; 
 
-       hFile = CreateFile(filename, GENERIC_WRITE, FILE_SHARE_WRITE, NULL,
-                                OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 
NULL);
+       hFile = CreateFile(filename, GENERIC_WRITE, 
FILE_SHARE_WRITE|FILE_SHARE_READ, NULL,
+                                OPEN_ALWAYS, FILE_FLAG_BACKUP_SEMANTICS, NULL);
+
+       /* OPEN_ALWAYS mode sets the last error to ERROR_ALREADY_EXISTS but 
+          the CreateFile operation succeeds */
+       if (GetLastError() == ERROR_ALREADY_EXISTS) {
+               SetLastError(0);
+       }
 
        if ( hFile == INVALID_HANDLE_VALUE ) {
                return -1;

http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/bug45985.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/file/bug45985.phpt
+++ php-src/ext/standard/tests/file/bug45985.phpt
--TEST--
Bug #35740 (touch() opened file raises a warning)
--FILE--
<?php
$file = __DIR__ . '/' . '__tmp_35740.dat';
file_put_contents($file, 'test');
$f = fopen($file, 'r');
touch($file);
fclose($f);
@unlink($file);
echo "ok";
?>
--EXPECT--
ok



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

Reply via email to