From 94d83073634759fb9996bf29f253a0dedc67ef19 Mon Sep 17 00:00:00 2001 From: Pierre Joye Date: Tue, 25 Aug 2009 09:16:53 +0000 Subject: [PATCH] - fix #49047, touch may fail on directory --- TSRM/tsrm_virtual_cwd.c | 2 +- TSRM/tsrm_virtual_cwd.h | 7 ++++++- TSRM/tsrm_win32.c | 2 +- TSRM/tsrm_win32.h | 1 + ext/standard/tests/file/bug49047.phpt | 17 +++++++++++++++++ 5 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 ext/standard/tests/file/bug49047.phpt diff --git a/TSRM/tsrm_virtual_cwd.c b/TSRM/tsrm_virtual_cwd.c index 634d7a1863..f40ebead0b 100644 --- a/TSRM/tsrm_virtual_cwd.c +++ b/TSRM/tsrm_virtual_cwd.c @@ -1192,7 +1192,7 @@ static void UnixTimeToFileTime(time_t t, LPFILETIME pft) /* {{{ */ } /* }}} */ -static int win32_utime(const char *filename, struct utimbuf *buf) /* {{{ */ +TSRM_API int win32_utime(const char *filename, struct utimbuf *buf) /* {{{ */ { FILETIME mtime, atime; HANDLE hFile; diff --git a/TSRM/tsrm_virtual_cwd.h b/TSRM/tsrm_virtual_cwd.h index 0b4ed266eb..145516f09a 100644 --- a/TSRM/tsrm_virtual_cwd.h +++ b/TSRM/tsrm_virtual_cwd.h @@ -328,8 +328,13 @@ CWD_API realpath_cache_bucket* realpath_cache_lookup(const char *path, int path_ #define VCWD_REALPATH(path, real_path) tsrm_realpath(path, real_path TSRMLS_CC) #if HAVE_UTIME -#define VCWD_UTIME(path, time) utime(path, time) +# ifdef TSRM_WIN32 +# define VCWD_UTIME(path, time) win32_utime(path, time) +# else +# define VCWD_UTIME(path, time) utime(path, time) +# endif #endif + #define VCWD_CHMOD(path, mode) chmod(path, mode) #if !defined(TSRM_WIN32) && !defined(NETWARE) #define VCWD_CHOWN(path, owner, group) chown(path, owner, group) diff --git a/TSRM/tsrm_win32.c b/TSRM/tsrm_win32.c index 59ebcb7564..e7a07ba8d8 100644 --- a/TSRM/tsrm_win32.c +++ b/TSRM/tsrm_win32.c @@ -171,7 +171,7 @@ TSRM_API int tsrm_win32_access(const char *pathname, int mode) fAccess = bucket->is_readable; goto Finished; } - desired_access = FILE_GENERIC_READ; + desired_access = FILE_GENERIC_READ|FILE_FLAG_BACKUP_SEMANTICS; } else { // if(mode <= 6) if(bucket != NULL && bucket->is_rvalid && bucket->is_wvalid) { fAccess = bucket->is_readable & bucket->is_writable; diff --git a/TSRM/tsrm_win32.h b/TSRM/tsrm_win32.h index 0fc952ad5a..e41db0327a 100644 --- a/TSRM/tsrm_win32.h +++ b/TSRM/tsrm_win32.h @@ -97,6 +97,7 @@ TSRM_API FILE *popen_ex(const char *command, const char *type, const char *cwd, TSRM_API FILE *popen(const char *command, const char *type); TSRM_API int pclose(FILE *stream); TSRM_API int tsrm_win32_access(const char *pathname, int mode); +TSRM_API int win32_utime(const char *filename, struct utimbuf *buf); TSRM_API int shmget(int key, int size, int flags); TSRM_API void *shmat(int key, const void *shmaddr, int flags); diff --git a/ext/standard/tests/file/bug49047.phpt b/ext/standard/tests/file/bug49047.phpt new file mode 100644 index 0000000000..1ccc94e287 --- /dev/null +++ b/ext/standard/tests/file/bug49047.phpt @@ -0,0 +1,17 @@ +--TEST-- +Test fopen() function : variation: interesting paths, no use include path +--FILE-- + +--EXPECTF-- +Ok. -- 2.40.0