cvs: php4 /ext/standard filestat.c

From: Date: Thu, 10 Jan 2002 07:21:57 +0000
Subject: cvs: php4 /ext/standard filestat.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-9024@lists.php.net to get a copy of this message
sas Thu Jan 10 02:21:57 2002 EDT Modified files: /php4/ext/standard filestat.c Log: Add three-parameter touch() which enables users to set mtime/atime to different values. Index: php4/ext/standard/filestat.c diff -u php4/ext/standard/filestat.c:1.86 php4/ext/standard/filestat.c:1.87 --- php4/ext/standard/filestat.c:1.86 Tue Dec 11 10:30:30 2001 +++ php4/ext/standard/filestat.c Thu Jan 10 02:21:57 2002 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: filestat.c,v 1.86 2001/12/11 15:30:30 sebastian Exp $ */ +/* $Id: filestat.c,v 1.87 2002/01/10 07:21:57 sas Exp $ */ #include "php.h" #include "safe_mode.h" @@ -465,12 +465,12 @@ } /* }}} */ -/* {{{ proto bool touch(string filename [, int time]) +/* {{{ proto bool touch(string filename [, int time [, int atime]]) Set modification time of file */ PHP_FUNCTION(touch) { #if HAVE_UTIME - pval **filename, **filetime; + pval **filename, **filetime, **fileatime; int ret; struct stat sb; FILE *file; @@ -484,8 +484,7 @@ php_error(E_WARNING, "unable to emalloc memory for changing time"); return; } - newtime->actime = time(NULL); - newtime->modtime = newtime->actime; + newtime->modtime = newtime->actime = time(NULL); #endif } else if (ac == 2 && zend_get_parameters_ex(2, &filename, &filetime) != FAILURE) { newtime = (struct utimbuf *)emalloc(sizeof(struct utimbuf)); @@ -494,7 +493,16 @@ return; } convert_to_long_ex(filetime); - newtime->actime = Z_LVAL_PP(filetime); + newtime->modtime = newtime->actime = Z_LVAL_PP(filetime); + } else if (ac == 3 && zend_get_parameters_ex(3, &filename, &filetime, &fileatime) != FAILURE) { + newtime = (struct utimbuf *)emalloc(sizeof(struct utimbuf)); + if (!newtime) { + php_error(E_WARNING, "unable to emalloc memory for changing time"); + return; + } + convert_to_long_ex(fileatime); + convert_to_long_ex(filetime); + newtime->actime = Z_LVAL_PP(fileatime); newtime->modtime = Z_LVAL_PP(filetime); } else { WRONG_PARAM_COUNT;

« previous php.cvs (#9024) next »