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.
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;
}
}
- 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);
* 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).
*
}
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;