]> granicus.if.org Git - php/commitdiff
- fix #49047, touch may fail on directory
authorPierre Joye <pajoye@php.net>
Tue, 25 Aug 2009 09:16:53 +0000 (09:16 +0000)
committerPierre Joye <pajoye@php.net>
Tue, 25 Aug 2009 09:16:53 +0000 (09:16 +0000)
TSRM/tsrm_virtual_cwd.c
TSRM/tsrm_virtual_cwd.h
TSRM/tsrm_win32.c
TSRM/tsrm_win32.h
ext/standard/tests/file/bug49047.phpt [new file with mode: 0644]

index 634d7a186366b2d3e3e063b1164948c3720c8886..f40ebead0ba2b916c5c466f99f49203ba06dec5b 100644 (file)
@@ -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; 
index 0b4ed266ebd912ebf7383da64e7f8c14c6221658..145516f09a56ca37d1c16820b8bb569229997821 100644 (file)
@@ -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)
index 59ebcb756447b59ef8e96badece2ea3c8ff14205..e7a07ba8d821d67874b0f3a2d4797dc2c980261b 100644 (file)
@@ -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;
index 0fc952ad5aab3979c13bdfd516864540312c7c9d..e41db0327ad5872a1d01aec8c0860cb417866025 100644 (file)
@@ -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 (file)
index 0000000..1ccc94e
--- /dev/null
@@ -0,0 +1,17 @@
+--TEST--\r
+Test fopen() function : variation: interesting paths, no use include path\r
+--FILE--\r
+<?php\r
+// fopen with interesting windows paths.\r
+$testdir = __DIR__ . '/bug47177.tmpdir';\r
+mkdir($testdir);\r
+$t = time() - 3600;\r
+touch($testdir, $t);\r
+clearstatcache();\r
+$t2 = filemtime($testdir);\r
+if ($t2 != $t) echo "failed (got $t2, expecting $t)\n";\r
+rmdir($testdir);\r
+echo "Ok.";\r
+?>\r
+--EXPECTF--\r
+Ok.\r