Skip to content

Commit

Permalink
- fix #49047, touch may fail on directory
Browse files Browse the repository at this point in the history
  • Loading branch information
pierrejoye committed Aug 25, 2009
1 parent 4c85f48 commit 056f0ae
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 3 deletions.
2 changes: 1 addition & 1 deletion TSRM/tsrm_virtual_cwd.c
Expand Up @@ -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;
Expand Down
7 changes: 6 additions & 1 deletion TSRM/tsrm_virtual_cwd.h
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion TSRM/tsrm_win32.c
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions TSRM/tsrm_win32.h
Expand Up @@ -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);
Expand Down
17 changes: 17 additions & 0 deletions ext/standard/tests/file/bug49047.phpt
@@ -0,0 +1,17 @@
--TEST--
Test fopen() function : variation: interesting paths, no use include path
--FILE--
<?php
// fopen with interesting windows paths.
$testdir = __DIR__ . '/bug47177.tmpdir';
mkdir($testdir);
$t = time() - 3600;
touch($testdir, $t);
clearstatcache();
$t2 = filemtime($testdir);
if ($t2 != $t) echo "failed (got $t2, expecting $t)\n";
rmdir($testdir);
echo "Ok.";
?>
--EXPECTF--
Ok.

0 comments on commit 056f0ae

Please sign in to comment.