diff --git a/src/tbox/platform/windows/directory.c b/src/tbox/platform/windows/directory.c index bccb03f8b..671d04ccf 100644 --- a/src/tbox/platform/windows/directory.c +++ b/src/tbox/platform/windows/directory.c @@ -62,6 +62,9 @@ static tb_long_t tb_directory_walk_copy(tb_char_t const* path, tb_file_info_t co tb_size_t size = tuple[1].ul; tb_char_t const* name = path + size; + // the copy flags + tb_size_t flags = tuple[2].ul; + // the dest file path tb_char_t dpath[8192] = {0}; tb_snprintf(dpath, 8192, "%s\\%s", dest, name[0] == '\\'? name + 1 : name); @@ -77,10 +80,12 @@ static tb_long_t tb_directory_walk_copy(tb_char_t const* path, tb_file_info_t co } // copy + tb_bool_t ok = tb_true; + tb_bool_t skip_recursion = tb_false; switch (info->type) { case TB_FILE_TYPE_FILE: - if (!tb_file_copy(path, dpath, TB_FILE_COPY_NONE)) tuple[2].b = tb_false; + ok = tb_file_copy(path, dpath, flags); break; case TB_FILE_TYPE_DIRECTORY: { @@ -97,7 +102,11 @@ static tb_long_t tb_directory_walk_copy(tb_char_t const* path, tb_file_info_t co default: break; } - return TB_DIRECTORY_WALK_CODE_CONTINUE; + tuple[3].b = ok; + tb_size_t retcode = TB_DIRECTORY_WALK_CODE_CONTINUE; + if (skip_recursion) + retcode |= TB_DIRECTORY_WALK_CODE_SKIP_RECURSION; + return retcode; } static tb_long_t tb_directory_walk_impl(tb_wchar_t const* path, tb_long_t recursion, tb_bool_t prefix, tb_directory_walk_func_t func, tb_cpointer_t priv) { @@ -330,7 +339,8 @@ tb_bool_t tb_directory_copy(tb_char_t const* path, tb_char_t const* dest, tb_siz tb_value_t tuple[3]; tuple[0].cstr = dest; tuple[1].ul = tb_strlen(path); - tuple[2].b = tb_true; + tuple[2].ul = flags; + tuple[3].b = tb_true; tb_directory_walk(path, -1, tb_true, tb_directory_walk_copy, tuple); // ok?