]> Kevux Git Server - fll/commitdiff
Feature: Support F_recurse_not to skip recursing directory for fl_directory_do().
authorKevin Day <Kevin@kevux.org>
Sun, 15 Jun 2025 00:03:50 +0000 (19:03 -0500)
committerKevin Day <Kevin@kevux.org>
Sun, 15 Jun 2025 00:03:50 +0000 (19:03 -0500)
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.

level_1/fl_directory/c/directory.c
level_1/fl_directory/c/directory.h
level_1/fl_directory/c/private-directory.c

index b19ccbc9e20ad4bfd338ea7daf5a116232265193..29e0cd2c8bf3866e0aa66ed8b8a03e15637b928a 100644 (file)
@@ -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);
index 489ffe80369ab5f0aa246bcd9997d686f758f811..27008393c14672b68c2956bc8c5151b73868a897 100644 (file)
@@ -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).
  *
index 2654057f7ec9888778904a44b7266181ae003313..e79b255bed128b69ea267d6b451996d639b089ca 100644 (file)
@@ -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;