Update: Add specific action flag for directory do recursion and fix integer type.
authorKevin Day <Kevin@kevux.org>
Thu, 30 Jan 2025 05:12:23 +0000 (23:12 -0600)
committerKevin Day <Kevin@kevux.org>
Thu, 30 Jan 2025 05:12:23 +0000 (23:12 -0600)
Add a specific action flag to make it easier to explicitly test if this is the action pass of say `fl_directory_do()`.

Use  `uint16_t` to directly map to the flag integer type.

level_0/f_directory/c/directory/common.h
level_1/fl_directory/c/private-directory.c

index 2fc61982079f556a241c6073d1d373dd6581b306..74af23770360b19a7337520289a07cd00ef4ba5b 100644 (file)
@@ -110,7 +110,8 @@ extern "C" {
  * f_directory_recurse_do_flag_*_e:
  *   For the recurse flag property.
  *   - none:        No flags are set.
- *   - after:       Perform this action after recursion befo a single directory path.
+ *   - action:      Perform the normal action.
+ *   - after:       Perform this action after recursion before a single directory path.
  *   - before:      Perform this action before recursion on a single directory path.
  *   - dereference: Dereference symbolic links rather than operating on the link itself.
  *   - list:        Perform this action after directory listing is loaded.
@@ -131,23 +132,24 @@ extern "C" {
   enum {
 
     // For the recurse flag property.
-    f_directory_recurse_do_flag_none_e        = 0,
-    f_directory_recurse_do_flag_after_e       = 0x1,
-    f_directory_recurse_do_flag_before_e      = 0x2,
-    f_directory_recurse_do_flag_dereference_e = 0x4,
-    f_directory_recurse_do_flag_list_e        = 0x8,
-    f_directory_recurse_do_flag_top_e         = 0x10,
+    f_directory_recurse_do_flag_none_e        = 0x0,
+    f_directory_recurse_do_flag_action_e      = 0x1,
+    f_directory_recurse_do_flag_after_e       = 0x2,
+    f_directory_recurse_do_flag_before_e      = 0x4,
+    f_directory_recurse_do_flag_dereference_e = 0x8,
+    f_directory_recurse_do_flag_list_e        = 0x10,
+    f_directory_recurse_do_flag_top_e         = 0x20,
 
     // For the action callback parameter.
-    f_directory_recurse_do_flag_block_e     = 0x20,
-    f_directory_recurse_do_flag_character_e = 0x40,
-    f_directory_recurse_do_flag_directory_e = 0x80,
-    f_directory_recurse_do_flag_fifo_e      = 0x100,
-    f_directory_recurse_do_flag_link_e      = 0x200,
-    f_directory_recurse_do_flag_path_e      = 0x400,
-    f_directory_recurse_do_flag_regular_e   = 0x800,
-    f_directory_recurse_do_flag_socket_e    = 0x1000,
-    f_directory_recurse_do_flag_unknown_e   = 0x2000,
+    f_directory_recurse_do_flag_block_e     = 0x40,
+    f_directory_recurse_do_flag_character_e = 0x80,
+    f_directory_recurse_do_flag_directory_e = 0x100,
+    f_directory_recurse_do_flag_fifo_e      = 0x200,
+    f_directory_recurse_do_flag_link_e      = 0x400,
+    f_directory_recurse_do_flag_path_e      = 0x800,
+    f_directory_recurse_do_flag_regular_e   = 0x1000,
+    f_directory_recurse_do_flag_socket_e    = 0x2000,
+    f_directory_recurse_do_flag_unknown_e   = 0x4000,
   }; // enum
 #endif // _di_f_directory_recurse_do_flag_e_
 
index bfea73538d48daadbedc3be4e14b1d032e094536..a720f54e24fe7f3193f3cb409ee7fb44b4fe0ee5 100644 (file)
@@ -64,9 +64,9 @@ extern "C" {
     uint8_t j = 0;
     const f_number_unsigned_t used_original = recurse->path.used;
 
-    static const uint8_t flag_actions[] = {
+    static const uint16_t flag_actions[] = {
       f_directory_recurse_do_flag_before_e,
-      0,
+      f_directory_recurse_do_flag_action_e,
       f_directory_recurse_do_flag_after_e,
     };
 
@@ -117,6 +117,7 @@ extern "C" {
 
           if (F_status_is_error(recurse->state.status)) {
             private_inline_fl_directory_do_handle(recurse, list[k]->array[i], f_directory_recurse_do_flag_directory_e);
+
             if (F_status_is_error(recurse->state.status)) break;
             if (recurse->state.status == F_break || recurse->state.status == F_done) break;
             if (recurse->state.status == F_continue) continue;