pajoye Thu Sep 4 08:03:31 2008 UTC
Added files:
/php-src/ext/standard/tests/file bug45985.phpt
Modified files:
/TSRM tsrm_virtual_cwd.c
Log:
- #45985, touch on opened file raises a warning
http://cvs.php.net/viewvc.cgi/TSRM/tsrm_virtual_cwd.c?r1=1.129&r2=1.130&diff_format=u
Index: TSRM/tsrm_virtual_cwd.c
diff -u TSRM/tsrm_virtual_cwd.c:1.129 TSRM/tsrm_virtual_cwd.c:1.130
--- TSRM/tsrm_virtual_cwd.c:1.129 Tue Aug 19 15:00:38 2008
+++ TSRM/tsrm_virtual_cwd.c Thu Sep 4 08:03:30 2008
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: tsrm_virtual_cwd.c,v 1.129 2008/08/19 15:00:38 dmitry Exp $ */
+/* $Id: tsrm_virtual_cwd.c,v 1.130 2008/09/04 08:03:30 pajoye Exp $ */
#include <sys/types.h>
#include <sys/stat.h>
@@ -1032,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