From: Yasuo Ohgaki Date: Fri, 26 Apr 2002 23:46:51 +0000 (+0000) Subject: Fixed bug #16861. X-Git-Tag: php-4.3.0dev-ZendEngine2-Preview1~410 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6cc8919dc4129bd79592532d387344e58e8b1f00;p=php Fixed bug #16861. touch sets wrong atime or mtime when they are not specified. touch silently failed when HAVE_UTIME is not defined. (This needs more consideration. Which platform does not support it?) # Derick, after HAVE_UTIME issue is resovled, this should be merged. # or we can just merge 1st problem for now. --- diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index 6a2ab33467..85be8bcf6e 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -680,7 +680,9 @@ function_entry basic_functions[] = { PHP_FE(chown, NULL) PHP_FE(chgrp, NULL) PHP_FE(chmod, NULL) +#if HAVE_UTIME PHP_FE(touch, NULL) +#endif PHP_FE(clearstatcache, NULL) PHP_FE(disk_total_space, NULL) PHP_FE(disk_free_space, NULL) diff --git a/ext/standard/filestat.c b/ext/standard/filestat.c index c74355dd80..d3d7abf658 100644 --- a/ext/standard/filestat.c +++ b/ext/standard/filestat.c @@ -465,17 +465,17 @@ PHP_FUNCTION(chmod) } /* }}} */ +#if HAVE_UTIME /* {{{ proto bool touch(string filename [, int time [, int atime]]) Set modification time of file */ PHP_FUNCTION(touch) { -#if HAVE_UTIME pval **filename, **filetime, **fileatime; int ret; struct stat sb; FILE *file; struct utimbuf newtimebuf; - struct utimbuf *newtime = &newtimebuf; + struct utimbuf *newtime = NULL; int ac = ZEND_NUM_ARGS(); if (ac == 1 && zend_get_parameters_ex(1, &filename) != FAILURE) { @@ -483,9 +483,12 @@ PHP_FUNCTION(touch) newtime->modtime = newtime->actime = time(NULL); #endif } else if (ac == 2 && zend_get_parameters_ex(2, &filename, &filetime) != FAILURE) { + newtime = &newtimebuf; convert_to_long_ex(filetime); + newtime->actime = time(NULL); newtime->modtime = newtime->actime = Z_LVAL_PP(filetime); } else if (ac == 3 && zend_get_parameters_ex(3, &filename, &filetime, &fileatime) != FAILURE) { + newtime = &newtimebuf; convert_to_long_ex(fileatime); convert_to_long_ex(filetime); newtime->actime = Z_LVAL_PP(fileatime); @@ -519,12 +522,11 @@ PHP_FUNCTION(touch) if (ret == -1) { php_error(E_WARNING, "utime failed: %s", strerror(errno)); RETURN_FALSE; - } else { - RETURN_TRUE; } -#endif + RETURN_TRUE; } /* }}} */ +#endif /* {{{ proto void clearstatcache(void) Clear file stat cache */ diff --git a/ext/standard/php_filestat.h b/ext/standard/php_filestat.h index 095e4f9292..62cd4f57b9 100644 --- a/ext/standard/php_filestat.h +++ b/ext/standard/php_filestat.h @@ -48,7 +48,9 @@ PHP_FUNCTION(disk_free_space); PHP_FUNCTION(chown); PHP_FUNCTION(chgrp); PHP_FUNCTION(chmod); +#if HAVE_UTIME PHP_FUNCTION(touch); +#endif PHP_FUNCTION(clearstatcache); #define MAKE_LONG_ZVAL_INCREF(name, val)\