Skip to content

Commit 459b614

Browse files
committed
fix uv_fs_scandir
1 parent 9d6e66d commit 459b614

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

php_uv.c

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1806,15 +1806,13 @@ static void php_uv_fs_cb(uv_fs_t* req)
18061806
zval *dirent;
18071807
int nnames, i = 0;
18081808
char *namebuf = (char *)req->ptr;
1809-
1809+
uv_dirent_t dent;
1810+
18101811
MAKE_STD_ZVAL(dirent);
18111812
array_init(dirent);
1812-
1813-
nnames = req->result;
1814-
for (i = 0; i < nnames; i++) {
1815-
add_next_index_string(dirent, namebuf, 1);
1816-
namebuf += strlen(namebuf) + 1;
1817-
}
1813+
while (UV_EOF != uv_fs_scandir_next(req, &dent)) {
1814+
add_next_index_string(dirent, dent.name, 1);
1815+
}
18181816

18191817
params[1] = &dirent;
18201818
break;
@@ -2924,6 +2922,13 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_uv_fs_readdir, 0, 0, 4)
29242922
ZEND_ARG_INFO(0, callback)
29252923
ZEND_END_ARG_INFO()
29262924

2925+
ZEND_BEGIN_ARG_INFO_EX(arginfo_uv_fs_scandir, 0, 0, 4)
2926+
ZEND_ARG_INFO(0, loop)
2927+
ZEND_ARG_INFO(0, path)
2928+
ZEND_ARG_INFO(0, flags)
2929+
ZEND_ARG_INFO(0, callback)
2930+
ZEND_END_ARG_INFO()
2931+
29272932
ZEND_BEGIN_ARG_INFO_EX(arginfo_uv_fs_fstat, 0, 0, 3)
29282933
ZEND_ARG_INFO(0, loop)
29292934
ZEND_ARG_INFO(0, fd)
@@ -6556,6 +6561,7 @@ static zend_function_entry uv_functions[] = {
65566561
PHP_FE(uv_fs_lstat, arginfo_uv_fs_lstat)
65576562
PHP_FE(uv_fs_fstat, arginfo_uv_fs_fstat)
65586563
PHP_FE(uv_fs_readdir, arginfo_uv_fs_readdir)
6564+
PHP_FE(uv_fs_scandir, arginfo_uv_fs_scandir)
65596565
PHP_FE(uv_fs_sendfile, arginfo_uv_fs_sendfile)
65606566
PHP_FE(uv_fs_event_init, arginfo_uv_fs_event_init)
65616567
/* tty */

0 commit comments

Comments
 (0)