]> 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 0cf7f25ff6e4e4703a87c327741ea7cf6e0b81c2..45e5e5c9acac2dde2707f5dde7ca70f56c7acc89 100644 (file)
@@ -1193,7 +1193,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 bc8f75d13d6c10b3e28030ad66935cd1a3f3e39c..39ff89e3e04d3a09c7995225db24e2f6fd02a24f 100644 (file)
@@ -311,8 +311,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 53cfa6175bdc260c8b6b5af1d75aaac447916160..bfaac2e446bf76c1a2d3d843bf74f658a9cf78cb 100644 (file)
@@ -170,7 +170,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 acd0e683a2727ec60f7adf88b7422b113e0669eb..402f2f4d6e0c6aec7f110f554903a8664b2367c9 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