diff options
author | Pierre Joye <pajoye@php.net> | 2008-09-04 08:05:27 +0000 |
---|---|---|
committer | Pierre Joye <pajoye@php.net> | 2008-09-04 08:05:27 +0000 |
commit | 5ec35396e0ed26cfc7c4856e7ffced4cac75003c (patch) | |
tree | 0cf3eef3ae5911c9ed61d892ecb2caa37766b8a2 | |
parent | 9bb39338dbcd429cbc9b4f0da406601c4b593970 (diff) | |
download | php-git-5ec35396e0ed26cfc7c4856e7ffced4cac75003c.tar.gz |
- MFH: #45985, touch on opened file raises a warning
-rw-r--r-- | TSRM/tsrm_virtual_cwd.c | 11 | ||||
-rw-r--r-- | ext/standard/tests/file/bug45985.phpt | 14 |
2 files changed, 22 insertions, 3 deletions
diff --git a/TSRM/tsrm_virtual_cwd.c b/TSRM/tsrm_virtual_cwd.c index bf3860547e..edbb9d8b07 100644 --- a/TSRM/tsrm_virtual_cwd.c +++ b/TSRM/tsrm_virtual_cwd.c @@ -818,7 +818,6 @@ CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func } #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 @@ static int win32_utime(const char *filename, struct utimbuf *buf) /* {{{ */ 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; diff --git a/ext/standard/tests/file/bug45985.phpt b/ext/standard/tests/file/bug45985.phpt new file mode 100644 index 0000000000..1b98da21aa --- /dev/null +++ b/ext/standard/tests/file/bug45985.phpt @@ -0,0 +1,14 @@ +--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 |