mirror of
https://github.com/danog/ext-uv.git
synced 2025-01-22 13:21:37 +01:00
add fs_utime, fs_ftime api
This commit is contained in:
parent
e40d4ff623
commit
8507b9e07f
3
TODO.md
3
TODO.md
@ -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_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_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);
|
||||
|
8
examples/utime.php
Normal file
8
examples/utime.php
Normal file
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
|
||||
uv_fs_utime(uv_default_loop(),__FILE__, time(), time(),function(){
|
||||
echo "Finished";
|
||||
});
|
||||
|
||||
uv_run();
|
59
php_uv.c
59
php_uv.c
@ -763,6 +763,10 @@ static void php_uv_fs_cb(uv_fs_t* req)
|
||||
argc = 1;
|
||||
break;
|
||||
}
|
||||
case UV_FS_UTIME:
|
||||
case UV_FS_FUTIME:
|
||||
argc = 0;
|
||||
break;
|
||||
case UV_FS_READ: {
|
||||
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[] = {
|
||||
/* general */
|
||||
@ -4002,6 +4059,8 @@ static zend_function_entry uv_functions[] = {
|
||||
PHP_FE(uv_fs_rmdir, NULL)
|
||||
PHP_FE(uv_fs_unlink, NULL)
|
||||
PHP_FE(uv_fs_rename, NULL)
|
||||
PHP_FE(uv_fs_utime, NULL)
|
||||
PHP_FE(uv_fs_futime, NULL)
|
||||
/* info */
|
||||
PHP_FE(uv_loadavg, NULL)
|
||||
PHP_FE(uv_uptime, NULL)
|
||||
|
Loading…
x
Reference in New Issue
Block a user