cvs: php4 /ext/standard basic_functions.c filestat.c php_filestat.h
| From: | Yasuo Ohgaki | Date: | Fri, 26 Apr 2002 23:46:51 +0000 |
| Subject: | cvs: php4 /ext/standard basic_functions.c filestat.c php_filestat.h | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-11464@lists.php.net to get a copy of this message | ||
yohgaki Fri Apr 26 19:46:51 2002 EDT
Modified files:
/php4/ext/standard basic_functions.c filestat.c php_filestat.h
Log:
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.
Index: php4/ext/standard/basic_functions.c
diff -u php4/ext/standard/basic_functions.c:1.470 php4/ext/standard/basic_functions.c:1.471
--- php4/ext/standard/basic_functions.c:1.470 Tue Apr 16 18:14:19 2002
+++ php4/ext/standard/basic_functions.c Fri Apr 26 19:46:49 2002
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: basic_functions.c,v 1.470 2002/04/16 22:14:19 wez Exp $ */
+/* $Id: basic_functions.c,v 1.471 2002/04/26 23:46:49 yohgaki Exp $ */
#include "php.h"
#include "php_streams.h"
@@ -680,7 +680,9 @@
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)
Index: php4/ext/standard/filestat.c
diff -u php4/ext/standard/filestat.c:1.89 php4/ext/standard/filestat.c:1.90
--- php4/ext/standard/filestat.c:1.89 Thu Feb 28 03:26:45 2002
+++ php4/ext/standard/filestat.c Fri Apr 26 19:46:51 2002
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: filestat.c,v 1.89 2002/02/28 08:26:45 sebastian Exp $ */
+/* $Id: filestat.c,v 1.90 2002/04/26 23:46:51 yohgaki Exp $ */
#include "php.h"
#include "safe_mode.h"
@@ -465,17 +465,17 @@
}
/* }}} */
+#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 @@
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 @@
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 */
Index: php4/ext/standard/php_filestat.h
diff -u php4/ext/standard/php_filestat.h:1.15 php4/ext/standard/php_filestat.h:1.16
--- php4/ext/standard/php_filestat.h:1.15 Tue Dec 11 10:30:35 2001
+++ php4/ext/standard/php_filestat.h Fri Apr 26 19:46:51 2002
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_filestat.h,v 1.15 2001/12/11 15:30:35 sebastian Exp $ */
+/* $Id: php_filestat.h,v 1.16 2002/04/26 23:46:51 yohgaki Exp $ */
#ifndef PHP_FILESTAT_H
#define PHP_FILESTAT_H
@@ -48,7 +48,9 @@
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)\