summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorruki <[email protected]>2018-05-02 23:13:20 +0800
committerruki <[email protected]>2018-05-02 13:20:01 +0800
commitcb8d8dcf2b7a698e7a6c31f1e58722b505132f32 (patch)
tree52c3aed8cbb74447258b76b53258a4ed94f89e5b /core
parent0bafe409d0687ebd429037907f15617fe4b42d53 (diff)
improve os.match and find_file
Diffstat (limited to 'core')
-rw-r--r--core/src/xmake/os/find.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/core/src/xmake/os/find.c b/core/src/xmake/os/find.c
index 3638a8219..79f281f2b 100644
--- a/core/src/xmake/os/find.c
+++ b/core/src/xmake/os/find.c
@@ -133,8 +133,27 @@ static tb_bool_t xm_os_find_walk(tb_char_t const* path, tb_file_info_t const* in
}
}
- // save this path
- if (!excluded) lua_rawseti(lua, -3, (tb_int_t)(++*pcount));
+ // does not exclude this path?
+ if (!excluded)
+ {
+ // save it
+ lua_rawseti(lua, -3, (tb_int_t)(++*pcount));
+
+ // do callback function
+ if (lua_isfunction(lua, 6))
+ {
+ // do callback(path, isdir)
+ lua_pushvalue(lua, 6);
+ lua_pushstring(lua, path);
+ lua_pushboolean(lua, info->type == TB_FILE_TYPE_DIRECTORY);
+ lua_call(lua, 2, 1);
+
+ // is continue?
+ tb_bool_t is_continue = lua_toboolean(lua, -1);
+ lua_pop(lua, 1);
+ if (!is_continue) return tb_false;
+ }
+ }
// pop this return value
else lua_pop(lua, 1);
}