From: Kevin Day Date: Sun, 15 Jun 2025 00:03:50 +0000 (-0500) Subject: Feature: Support F_recurse_not to skip recursing directory for fl_directory_do(). X-Git-Tag: 0.7.2~11 X-Git-Url: https://www.git.kevux.org/?a=commitdiff_plain;h=62eb05d3a3a360ca0118b93ed45a2638cabcb7e1;p=fll Feature: Support F_recurse_not to skip recursing directory for fl_directory_do(). The `fl_directory_do()` should support skipping directory recursion itself. Add `F_recurse_not` checks before recursion. The `F_recurse_not` does not prevent the action on the directory itself. --- diff --git a/level_1/fl_directory/c/directory.c b/level_1/fl_directory/c/directory.c index b19ccbc..29e0cd2 100644 --- a/level_1/fl_directory/c/directory.c +++ b/level_1/fl_directory/c/directory.c @@ -154,7 +154,10 @@ extern "C" { if (flag_actions[action]) { if (flag_actions[action] & f_directory_recurse_do_flag_action_d) { - if (recurse->depth < recurse->depth_max) { + if (recurse->state.status == F_recurse_not) { + recurse->state.status = F_okay; + } + else if (recurse->depth < recurse->depth_max) { recurse->state.status = F_okay; ++recurse->depth; @@ -177,7 +180,7 @@ extern "C" { } } - if (flag_actions[action] != f_directory_recurse_do_flag_action_d || recurse->flag & f_directory_recurse_do_flag_action_d) { + if (flag_actions[action] != f_directory_recurse_do_flag_action_d || (recurse->flag & f_directory_recurse_do_flag_action_d)) { recurse->state.status = F_okay; recurse->action(recurse, path, flag_actions[action] | f_directory_recurse_do_flag_directory_d); diff --git a/level_1/fl_directory/c/directory.h b/level_1/fl_directory/c/directory.h index 489ffe8..2700839 100644 --- a/level_1/fl_directory/c/directory.h +++ b/level_1/fl_directory/c/directory.h @@ -111,10 +111,11 @@ extern "C" { * The after only happens if recurse.flag has f_directory_recurse_do_flag_after_d. * * Setting the recurse.state.status to the following for the designated effects: - * - F_break: Break out of the current depth; Is the same as F_done at depth 0. - * - F_continue: Continue to the next sibling file at the current depth; Is the same as F_done at depth 0. - * - F_done: Done all directory operations, immediately return. - * - F_skip: Skip the next action, resetting the recurse.state.status to F_okay; Is the same as F_okay if on the last action for some path. + * - F_break: Break out of the current depth; Is the same as F_done at depth 0. + * - F_continue: Continue to the next sibling file at the current depth; Is the same as F_done at depth 0. + * - F_done: Done all directory operations, immediately return. + * - F_recurse_not: Do not recurse into sub-directory (only applies to directories and must be assign during the f_directory_recurse_do_flag_before_d step for each path). + * - F_skip: Skip the next action, resetting the recurse.state.status to F_okay; Is the same as F_okay if on the last action for some path. * * The action() and handle() should check if the recurse is NULL (and any other appropraite NULL checks). * diff --git a/level_1/fl_directory/c/private-directory.c b/level_1/fl_directory/c/private-directory.c index 2654057..e79b255 100644 --- a/level_1/fl_directory/c/private-directory.c +++ b/level_1/fl_directory/c/private-directory.c @@ -137,7 +137,10 @@ extern "C" { } if (flag_actions[action]) { - if ((flag & f_directory_recurse_do_flag_directory_d) && (flag_actions[action] & f_directory_recurse_do_flag_action_d)) { + if (recurse->state.status == F_recurse_not) { + recurse->state.status = F_okay; + } + else if ((flag & f_directory_recurse_do_flag_directory_d) && (flag_actions[action] & f_directory_recurse_do_flag_action_d)) { recurse->state.status = F_okay; used_directory = recurse->path.used;