add fs_utime, fs_ftime api

This commit is contained in:
Shuhei Tanuma 2012-06-23 01:58:00 +09:00
parent e40d4ff623
commit 8507b9e07f
3 changed files with 67 additions and 3 deletions

View File

@ -54,9 +54,6 @@
* UV_EXTERN int uv_fs_chown(uv_loop_t* loop, uv_fs_t* req, const char* path,int uid, int gid, uv_fs_cb cb); * UV_EXTERN int uv_fs_chown(uv_loop_t* loop, uv_fs_t* req, const char* path,int uid, int gid, uv_fs_cb cb);
* UV_EXTERN int uv_fs_fchown(uv_loop_t* loop, uv_fs_t* req, uv_file file,int uid, int gid, uv_fs_cb cb); * UV_EXTERN int uv_fs_fchown(uv_loop_t* loop, uv_fs_t* req, uv_file file,int uid, int gid, uv_fs_cb cb);
* UV_EXTERN int uv_fs_utime(uv_loop_t* loop, uv_fs_t* req, const char* path,double atime, double mtime, uv_fs_cb cb);
* UV_EXTERN int uv_fs_futime(uv_loop_t* loop, uv_fs_t* req, uv_file file,double atime, double mtime, uv_fs_cb cb);
* UV_EXTERN int uv_fs_link(uv_loop_t* loop, uv_fs_t* req, const char* path,const char* new_path, uv_fs_cb cb); * UV_EXTERN int uv_fs_link(uv_loop_t* loop, uv_fs_t* req, const char* path,const char* new_path, uv_fs_cb cb);
* UV_EXTERN int uv_fs_symlink(uv_loop_t* loop, uv_fs_t* req, const char* path,const char* new_path, int flags, uv_fs_cb cb); * UV_EXTERN int uv_fs_symlink(uv_loop_t* loop, uv_fs_t* req, const char* path,const char* new_path, int flags, uv_fs_cb cb);
* UV_EXTERN int uv_fs_readlink(uv_loop_t* loop, uv_fs_t* req, const char* path,uv_fs_cb cb); * UV_EXTERN int uv_fs_readlink(uv_loop_t* loop, uv_fs_t* req, const char* path,uv_fs_cb cb);

8
examples/utime.php Normal file
View File

@ -0,0 +1,8 @@
<?php
uv_fs_utime(uv_default_loop(),__FILE__, time(), time(),function(){
echo "Finished";
});
uv_run();

View File

@ -763,6 +763,10 @@ static void php_uv_fs_cb(uv_fs_t* req)
argc = 1; argc = 1;
break; break;
} }
case UV_FS_UTIME:
case UV_FS_FUTIME:
argc = 0;
break;
case UV_FS_READ: { case UV_FS_READ: {
zval *buffer; zval *buffer;
@ -3900,6 +3904,59 @@ PHP_FUNCTION(uv_fs_rename)
} }
/* }}} */ /* }}} */
/* {{{ */
PHP_FUNCTION(uv_fs_utime)
{
int error;
zval *callback, *tmp, *zloop = NULL;
uv_loop_t *loop;
php_uv_t *uv;
long utime, atime;
char *path;
int path_len = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
"zsllz", &zloop, &path, &path_len, &utime, &atime, &callback) == FAILURE) {
return;
}
PHP_UV_INIT_UV(uv, IS_UV_FS);
PHP_UV_FETCH_UV_DEFAULT_LOOP(loop, zloop);
uv->fs_cb = callback;
Z_ADDREF_P(callback);
uv->uv.fs.data = uv;
PHP_UV_FS_ASYNC(loop, utime, path, utime, atime);
}
/* }}} */
/* {{{ */
PHP_FUNCTION(uv_fs_futime)
{
int error;
zval *callback, *tmp, *zloop = NULL;
uv_loop_t *loop;
php_uv_t *uv;
long utime, atime;
unsigned long fd;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
"zlllz", &zloop, &fd, &utime, &atime, &callback) == FAILURE) {
return;
}
PHP_UV_INIT_UV(uv, IS_UV_FS);
PHP_UV_FETCH_UV_DEFAULT_LOOP(loop, zloop);
uv->fs_cb = callback;
Z_ADDREF_P(callback);
uv->uv.fs.data = uv;
PHP_UV_FS_ASYNC(loop, futime, fd, utime, atime);
}
/* }}} */
static zend_function_entry uv_functions[] = { static zend_function_entry uv_functions[] = {
/* general */ /* general */
@ -4002,6 +4059,8 @@ static zend_function_entry uv_functions[] = {
PHP_FE(uv_fs_rmdir, NULL) PHP_FE(uv_fs_rmdir, NULL)
PHP_FE(uv_fs_unlink, NULL) PHP_FE(uv_fs_unlink, NULL)
PHP_FE(uv_fs_rename, NULL) PHP_FE(uv_fs_rename, NULL)
PHP_FE(uv_fs_utime, NULL)
PHP_FE(uv_fs_futime, NULL)
/* info */ /* info */
PHP_FE(uv_loadavg, NULL) PHP_FE(uv_loadavg, NULL)
PHP_FE(uv_uptime, NULL) PHP_FE(uv_uptime, NULL)