]> Kevux Git Server - kevux-tools/commitdiff
Progress: Continue working on completing the remove program.
authorKevin Day <Kevin@kevux.org>
Sun, 13 Apr 2025 03:12:51 +0000 (22:12 -0500)
committerKevin Day <Kevin@kevux.org>
Sun, 13 Apr 2025 03:51:59 +0000 (22:51 -0500)
Add normal allocation length define and shrink the path to this size if the size is larger than the large length.

Restructure the simulate to be called during the directory recursion so that there is only a single `fl_directory_do()` recursion.
The simulate must not be aware of when it is being called during recursion and when it is not being called during recursion.
The directory has to be processed to determine if and when it is being recursed.
However, the directory should be deleted after recursion into its child paths.
Update the unit rests accordingly.

The directory recursion is now moved into a top level cache.
This reduces the amount of allocations necessary and makes clean up on exit easier.

The parent path logic needs to be updated.
I added sample snippet of code with a todo, commented out.

Remove some stale documentation comments.

I did some basic tests using (with and without `-S` added):
```
clear ; md a/b/c/d && touch a/b/file.txt && valgrind --leak-check=full remove +V a/b -r ; t a
```

And (with and without `-S` added):
```
clear ; md a/b/{c/d,e/f} && touch a/b/file.txt && valgrind --leak-check=full remove +V a/b -r ; t a
```

The file statistics for the top-level directory being recursed needs to be preserved and passed through to the simulate.
The first directory processing pass before recursion should retain this.
During recursion, the parent directory should utilize this information when needed.

24 files changed:
sources/c/program/kevux/tools/remove/main/common/define.h
sources/c/program/kevux/tools/remove/main/common/type.c
sources/c/program/kevux/tools/remove/main/common/type.h
sources/c/program/kevux/tools/remove/main/operate.c
sources/c/program/kevux/tools/remove/main/operate.h
sources/c/program/kevux/tools/remove/main/preprocess.c
sources/c/program/kevux/tools/remove/main/preprocess.h
sources/c/program/kevux/tools/remove/main/print/error.c
sources/c/program/kevux/tools/remove/main/print/error.h
sources/c/program/kevux/tools/remove/main/print/simulate.c
sources/c/program/kevux/tools/remove/main/print/simulate.h
sources/c/program/kevux/tools/remove/main/remove.c
tests/unit/remove/c/test-remove-date_accessed.c
tests/unit/remove/c/test-remove-date_changed.c
tests/unit/remove/c/test-remove-date_updated.c
tests/unit/remove/c/test-remove-directory_no_args.c
tests/unit/remove/c/test-remove-directory_recurse_simple.c
tests/unit/remove/c/test-remove-epochtime.c
tests/unit/remove/c/test-remove-file_mode.c
tests/unit/remove/c/test-remove-file_type.c
tests/unit/remove/c/test-remove-group.c
tests/unit/remove/c/test-remove-time.c
tests/unit/remove/c/test-remove-unix.c
tests/unit/remove/c/test-remove-user.c

index e69a2c2e0373ef8fc7d00196caa72efceab75f19..f3637ea8a6581d1b0eaa0984e7076bb7bfd4e857 100644 (file)
@@ -65,17 +65,43 @@ extern "C" {
  * control_allocation_*_d:
  *   - console: An allocation step used for small buffers specifically for console parameter.
  *   - large:   An allocation step used for buffers that are anticipated to have large buffers.
+ *   - normal:  An allocation size to set to when shrinking an over sized array.
  *   - pipe:    A buffer size used for processing piped data.
  *   - small:   An allocation step used for buffers that are anticipated to have small buffers.
  */
 #ifndef _di_kt_remove_allocation_d_
   #define kt_remove_allocation_console_d 4
   #define kt_remove_allocation_large_d   2048
+  #define kt_remove_allocation_normal_d  256
   #define kt_remove_allocation_pipe_d    16384
   #define kt_remove_allocation_small_d   8
 #endif // _di_kt_remove_allocation_d_
 
 /**
+ * Flags associated with performing an operation on a file.
+ *
+ * kt_remove_flag_simulate_*_d:
+ *   - none:              No flags set, simulate disabled, no "is" value.
+ *   - directory:         Simulate directory, not recursing.
+ *   - directory_any:     Helper used to represent the directory, directory_not, and directory_recurse bits.
+ *   - directory_not:     Simulate non-directory, not recursing.
+ *   - directory_recurse: Simulate directory, recursing.
+ *   - is_a:              Print simulate message related to "is a ".
+ *   - is_a_file:         Helper used to print both simulate messages related to "is a " and "a file".
+ *   - is_file:           Print simulate message related to "a file".
+ */
+#ifndef _di_kt_remove_flag_file_simulate_d_
+  #define kt_remove_flag_simulate_none_d              0x0
+  #define kt_remove_flag_simulate_directory_d         0x1
+  #define kt_remove_flag_simulate_directory_any_d     0x7
+  #define kt_remove_flag_simulate_directory_not_d     0x2
+  #define kt_remove_flag_simulate_directory_recurse_d 0x4
+  #define kt_remove_flag_simulate_is_a_d              0x8
+  #define kt_remove_flag_simulate_is_a_file_d         0x18
+  #define kt_remove_flag_simulate_is_file_d           0x10
+#endif // _di_kt_remove_flag_file_code_d_
+
+/**
  * A set of flags used internally in the convert process.
  *
  * These are generally used during parsing of Time and EpochTime strings.
index 39e5fcdba2d1157616fa468836031c32688d7d0d..a2f14de06d4fa7d15b603d2fe5b227f4bbdd6660 100644 (file)
@@ -17,6 +17,8 @@ extern "C" {
     f_memory_arrays_resize(0, sizeof(f_string_dynamic_t), (void **) &cache->files.array, &cache->files.used, &cache->files.size, &f_string_dynamics_delete_callback);
     f_memory_arrays_resize(0, sizeof(f_string_dynamic_t), (void **) &cache->memory.array, &cache->memory.used, &cache->memory.size, &f_string_dynamics_delete_callback);
     f_memory_arrays_resize(0, sizeof(f_string_dynamic_t), (void **) &cache->tree.array, &cache->tree.used, &cache->tree.size, &f_string_dynamics_delete_callback);
+
+    f_directory_recurse_do_delete(&cache->recurse);
   }
 #endif // _di_kt_remove_cache_delete_
 
index adbd98c9a0211c47ae4cd488896e4c9355f56a44..4fa864158189c569aea607da767e7d19afa542cb 100644 (file)
@@ -140,32 +140,44 @@ extern "C" {
 /**
  * The program cache.
  *
- * polls:  An array of poll structures.
+ * statistics: The statistics of the parent directory before recursion takes place.
+ *
+ * polls: An array of poll structures.
+ *
  * buffer: The generic buffer.
  * input:  The buffer used specifically for handling input.
+ *
  * files:  A collection of files, often used during path recursion like those associated with the tree parameter.
  * memory: A list of paths or partial paths representing files already processed.
  * tree:   A collection of files to process as a result of the --tree command.
+ *
+ * recurse: Directory recurse data.
  */
 #ifndef _di_kt_remove_cache_t_
   typedef struct {
+    struct stat statistics;
     f_polls_t polls;
 
     f_string_dynamic_t buffer;
     f_string_dynamic_t input;
+
     f_string_dynamics_t files;
     f_string_dynamics_t memory;
     f_string_dynamics_t tree;
+
+    f_directory_recurse_do_t recurse;
   } kt_remove_cache_t;
 
   #define kt_remove_cache_t_initialize \
     { \
+      { 0 }, \
       f_polls_t_initialize, \
       f_string_dynamic_t_initialize, \
       f_string_dynamic_t_initialize, \
       f_string_dynamics_t_initialize, \
       f_string_dynamics_t_initialize, \
       f_string_dynamics_t_initialize, \
+      f_directory_recurse_do_t_initialize, \
     }
 #endif // _di_kt_remove_cache_t_
 
index 337765d1757dabbfc5a390617c4f6bedd75c6e8c..b896c483affb9fb99bd4e7e32e581c31118526b7 100644 (file)
@@ -9,41 +9,49 @@ extern "C" {
 
     if (!kt_remove_operate_shall_remove(flag_operate)) return (flag_operate & kt_remove_flag_file_operate_remove_fail_d) ? F_status_set_error(F_no) : F_no;
 
-    f_directory_recurse_do_t recurse = f_directory_recurse_do_t_initialize;
-
     // The recurse.state.code flags represent the top-level directory being recursed on.
-    recurse.state.code = (uint64_t) flag_operate;
-    recurse.state.custom = (void *) main;
-    recurse.state.interrupt = &kt_remove_signal_check_recurse;
+    main->cache.recurse.state.code = (uint64_t) flag_operate;
+    main->cache.recurse.state.custom = (void *) main;
+    main->cache.recurse.state.interrupt = &kt_remove_signal_check_recurse;
 
-    recurse.depth_max = main->setting.flag & kt_remove_main_flag_recurse_d ? kt_remove_depth_max_d : 0;
-    recurse.flag = 0;
-    recurse.path_top = &path;
+    main->cache.recurse.depth_max = main->setting.flag & kt_remove_main_flag_recurse_d ? kt_remove_depth_max_d : 0;
+    main->cache.recurse.flag = 0;
+    main->cache.recurse.path.used = 0;
+    main->cache.recurse.path_top = &path;
 
-    recurse.action = &kt_remove_operate_recurse_action;
-    recurse.handle = &kt_remove_operate_recurse_handle;
+    main->cache.recurse.action = &kt_remove_operate_recurse_action;
+    main->cache.recurse.handle = &kt_remove_operate_recurse_handle;
 
-    fl_directory_do(path, &recurse);
-    if (F_status_is_error(recurse.state.status)) return recurse.state.status;
+    fl_directory_do(path, &main->cache.recurse);
+    if (F_status_is_error(main->cache.recurse.state.status)) return main->cache.recurse.state.status;
 
-    f_status_t status_remove = F_no;
+    // Shrink path if oversized.
+    if (main->cache.recurse.path.used > kt_remove_allocation_large_d) {
+      const f_status_t status = f_memory_array_resize(kt_remove_allocation_normal_d, sizeof(f_char_t), (void **) &main->cache.recurse.path.string, &main->cache.recurse.path.used, &main->cache.recurse.path.size);
 
-    // Remove the directory, if not simulating.
-    if (!(main->setting.flag & kt_remove_main_flag_simulate_d)) {
-      status_remove = kt_remove_operate_remove(main, path, flag_operate);
+      if (F_status_is_error(status)) {
+        kt_remove_print_error(&main->program.error, macro_kt_remove_f(f_memory_array_resize));
+
+        return status;
+      }
     }
 
-    {
-      const f_status_t status = f_directory_recurse_do_delete(&recurse);
-      if (F_status_is_error(status)) return status;
+    // Remove the directory, if not simulating.
+    if (main->setting.flag & kt_remove_main_flag_simulate_d) {
+      fll_print_dynamic(f_string_eol_s, main->program.output.to);
+
+      kt_remove_preprocess_file(main, path, 0, 0x2);
+    }
+    else {
+      return kt_remove_operate_remove(main, path, flag_operate);
     }
 
-    return status_remove;
+    return F_no;
   }
 #endif // _di_kt_remove_operate_directory_
 
 #ifndef _di_kt_remove_operate_file_
-  f_status_t kt_remove_operate_file(kt_remove_main_t * const main, const f_string_static_t path) {
+  f_status_t kt_remove_operate_file(kt_remove_main_t * const main, const f_string_static_t path, const uint8_t recurse) {
 
     if (!main) return F_status_set_error(F_parameter);
     if (!path.used) return F_data_not;
@@ -51,7 +59,7 @@ extern "C" {
 
     if (macro_kt_remove_signal_check(&main->program, &main->setting.state)) return F_status_set_error(F_interrupt);
 
-    const uint32_t flag_operate = kt_remove_preprocess_file(main, path, 0);
+    const uint32_t flag_operate = kt_remove_preprocess_file(main, path, 0, recurse);
 
     if (F_status_is_error(main->setting.state.status)) return main->setting.state.status;
     if (flag_operate & kt_remove_flag_file_operate_processed_d) return F_no;
@@ -69,7 +77,7 @@ extern "C" {
       main->setting.state.status = kt_remove_operate_file_prompt(main, path, flag_operate);
       if (F_status_is_error(main->setting.state.status)) return main->setting.state.status;
 
-      return (flag_operate & kt_remove_flag_file_operate_directory_d)
+      return (flag_operate & kt_remove_flag_file_operate_directory_d) && !recurse
         ? kt_remove_operate_directory(main, path, flag_operate)
         : !(main->setting.flag & kt_remove_main_flag_simulate_d)
           ? kt_remove_operate_remove(main, path, flag_operate)
@@ -93,7 +101,32 @@ extern "C" {
 
     if (macro_kt_remove_signal_check(&main->program, &main->setting.state)) return;
 
-    const uint32_t flag_operate = kt_remove_preprocess_file(main, path, kt_remove_flag_file_operate_parent_d);
+    // @todo update this function, the related kt_remove_operate_file() has newer practices that need to be reflected here.
+    /*
+    const uint32_t flag_operate = kt_remove_preprocess_file(main, path, 0, recurse);
+
+    if (F_status_is_error(main->setting.state.status)) return main->setting.state.status;
+    if (flag_operate & kt_remove_flag_file_operate_processed_d) return F_no;
+
+    if (flag_operate & kt_remove_flag_file_operate_missing_d) {
+      if (!(main->setting.flag & kt_remove_main_flag_force_simulate_d)) {
+        main->setting.state.status = F_status_set_error(F_file_found_not);
+
+        kt_remove_print_error_file(&main->program.error, macro_kt_remove_f(kt_remove_preprocess_file), path, f_file_operation_delete_s, fll_error_file_type_file_e);
+
+        return main->setting.state.status;
+      }
+    }
+    else if (main->setting.state.status != F_skip) {
+      main->setting.state.status = kt_remove_operate_file_prompt(main, path, flag_operate);
+      if (F_status_is_error(main->setting.state.status)) return main->setting.state.status;
+
+      return !(main->setting.flag & kt_remove_main_flag_simulate_d)
+        ? kt_remove_operate_remove(main, path, flag_operate)
+        : F_no;
+    }*/
+
+    const uint32_t flag_operate = kt_remove_preprocess_file(main, path, kt_remove_flag_file_operate_parent_d, F_false);
 
     if (!kt_remove_operate_shall_remove(flag_operate) || (main->setting.flag & kt_remove_main_flag_simulate_d)) return;
 
@@ -344,7 +377,7 @@ extern "C" {
       f_print_dynamic(f_string_eol_s, main->program.output.to);
     }
 
-    recurse->state.status = kt_remove_operate_file(main, recurse->path);
+    recurse->state.status = kt_remove_operate_file(main, recurse->path, F_true);
 
     if (F_status_is_error_not(recurse->state.status)) {
       recurse->state.status = F_okay;
index e9e587e5a41163546354049df8d7aed548e41258..9d4e393b961af06470aba30c6c75c443c4b3600a 100644 (file)
@@ -34,12 +34,13 @@ extern "C" {
  *   F_no (with error bit) on failure and file is not to be removed or cannot be removed.
  *   F_recurse (with error bit) on max recursion depth reached.
  *
- *   Errors (with error bit) from: f_directory_recurse_do_delete()
+ *   Errors (with error bit) from: f_memory_array_resize()
  *   Errors (with error bit) from: fl_directory_do()
+ *   Errors (with error bit) from: kt_remove_operate_remove()
  *
- * @see f_directory_recurse_do_delete()
- * @see f_file_remove()
+ * @see f_memory_array_resize()
  * @see fl_directory_do()
+ * @see kt_remove_operate_remove()
  */
 #ifndef _di_kt_remove_operate_directory_
   extern f_status_t kt_remove_operate_directory(kt_remove_main_t * const main, const f_string_static_t path, const uint32_t flag_operate);
@@ -60,12 +61,9 @@ extern "C" {
  *   This should always be TRUE when calling from the top level.
  *   This should always be FALSE if calling from within a fl_directory_do() callback.
  *   This is because fl_directory_do() handles directory traversal and processing.
- * @param state
- *   The state information for processing.
- *   A new state should be created rather than using the main.setting.state to prevent conflicts during recursion.
- *   The first state outside of recursion can use main.setting.state.
- *
- *   Must not be NULL.
+ * @param recurse
+ *   If F_true, then this function is being called during directory recursion.
+ *   If F_false, then this function is being called outside of directory recursion.
  *
  * @return
  *   F_yes on success and removed.
@@ -90,7 +88,7 @@ extern "C" {
  * @see kt_remove_preprocess_file()
  */
 #ifndef _di_kt_remove_operate_file_
-  extern f_status_t kt_remove_operate_file(kt_remove_main_t * const main, const f_string_static_t path);
+  extern f_status_t kt_remove_operate_file(kt_remove_main_t * const main, const f_string_static_t path, const uint8_t recurse);
 #endif // _di_kt_remove_operate_file_
 
 /**
@@ -134,9 +132,10 @@ extern "C" {
  *   Must not be NULL.
  *
  *   This does not alter main.setting.state.status.
- *
  * @param path
  *   The path to the file to operate on.
+ * @param flag_operate
+ *   The operate file specific flags from kt_remove_flag_file_operate_*_e.
  *
  * @return
  *   F_okay on success or if prompting is not requested.
index 492f17b2ac6099cab5f61d81ca8fb1b09f988792..bd87d077a4efe7d2f3a90e7639da3e3cb1806218 100644 (file)
@@ -5,7 +5,7 @@ extern "C" {
 #endif
 
 #ifndef _di_kt_remove_preprocess_file_
-  uint16_t kt_remove_preprocess_file(kt_remove_main_t * const main, const f_string_static_t path, const uint32_t flag_operate) {
+  uint16_t kt_remove_preprocess_file(kt_remove_main_t * const main, const f_string_static_t path, const uint32_t flag_operate, const uint8_t recurse) {
 
     if (!main) return 0;
 
@@ -19,17 +19,21 @@ extern "C" {
 
     uint32_t flag_out = (main->setting.flag & kt_remove_main_flag_option_type_used_d) ? 0 : kt_remove_flag_file_operate_remove_d;
 
+    uint8_t simulate = (main->setting.flag & kt_remove_main_flag_simulate_d)
+        ? kt_remove_flag_simulate_directory_not_d
+        : kt_remove_flag_simulate_none_d;
+
     kt_remove_operate_memory_check(main, path, &flag_out);
     if (F_status_is_error(main->setting.state.status) || (flag_out & kt_remove_flag_file_operate_processed_d)) return flag_out;
 
-    kt_remove_print_simulate_operate_file(&main->program.output, path, flag_operate);
-
     main->setting.state.status = f_file_exists(path, main->setting.flag & kt_remove_main_flag_follow_d);
 
     if (main->setting.state.status == F_true) {
       const f_status_t status = f_file_is(path, F_file_type_link_d, F_false);
 
       if (F_status_is_error(status)) {
+        kt_remove_print_simulate_operate_file(&main->program.output, simulate, path, flag_operate);
+
         main->setting.state.status = status;
 
         remove_print_warning_file_reason(&main->program.warning, path, kt_remove_print_reason_stat_fail_s);
@@ -41,29 +45,22 @@ extern "C" {
         flag_out |= kt_remove_flag_file_operate_link_d;
       }
     }
+    else if (main->setting.state.status == F_false || F_status_is_error(main->setting.state.status)) {
+      kt_remove_print_simulate_operate_file(&main->program.output, simulate, path, flag_operate);
 
-    kt_remove_print_simulate_operate_file_exists(&main->program.output, path, flag_out);
+      kt_remove_print_simulate_operate_file_exists(&main->program.output, simulate, path, flag_out);
 
-    if (main->setting.state.status == F_false) {
-      if (main->setting.flag & kt_remove_main_flag_simulate_d) {
-        kt_remove_print_simulate_operate_boolean(&main->program.output, kt_remove_ignore_s, main->setting.flag & kt_remove_main_flag_force_d);
-      }
+      if (main->setting.state.status == F_false) {
+        kt_remove_print_simulate_operate_boolean(&main->program.output, simulate, kt_remove_ignore_s, main->setting.flag & kt_remove_main_flag_force_d);
 
-      return kt_remove_flag_file_operate_missing_d;
-    }
+        return kt_remove_flag_file_operate_missing_d;
+      }
 
-    if (F_status_is_error(main->setting.state.status)) {
       remove_print_warning_file_reason(&main->program.warning, path, kt_remove_print_reason_no_access_s);
 
       return 0;
     }
 
-    if (main->setting.state.status == F_false) {
-      kt_remove_print_simulate_operate_boolean(&main->program.output, kt_remove_remove_s, F_false);
-
-      return 0;
-    }
-
     if (macro_kt_remove_signal_check(&main->program, &main->setting.state)) return 0;
 
     if (main->setting.flag & kt_remove_main_flag_follow_d) {
@@ -76,35 +73,61 @@ extern "C" {
 
     memset(&statistics, 0, sizeof(struct stat));
 
-    main->setting.state.status = f_file_stat(path, main->setting.flag & kt_remove_main_flag_follow_d, &statistics);
-
-    if (F_status_is_error(main->setting.state.status)) {
-      remove_print_warning_file_reason(&main->program.warning, path, kt_remove_print_reason_stat_fail_s);
-
-      return flag_out;
+    if (recurse == 0x2) {
+      memcpy(&statistics, &main->cache.statistics, sizeof(struct stat));
     }
+    else {
+      main->setting.state.status = f_file_stat(path, main->setting.flag & kt_remove_main_flag_follow_d, &statistics);
 
-    kt_remove_preprocess_file_type(main, path, macro_f_file_type_is_block(statistics.st_mode), f_file_type_name_block_s, kt_remove_main_flag_block_d, kt_remove_main_flag_block_ignore_d, 0x1, &flag_out);
+      if (F_status_is_error(main->setting.state.status)) {
+        kt_remove_print_simulate_operate_file(&main->program.output, simulate, path, flag_operate);
 
-    kt_remove_preprocess_file_type(main, path, macro_f_file_type_is_character(statistics.st_mode), f_file_type_name_character_s, kt_remove_main_flag_character_d, kt_remove_main_flag_character_ignore_d, 0x1, &flag_out);
+        kt_remove_print_simulate_operate_file_exists(&main->program.output, simulate, path, flag_out);
 
-    kt_remove_preprocess_file_type(main, path, macro_f_file_type_is_directory(statistics.st_mode), f_file_type_name_directory_s, kt_remove_main_flag_directory_d, kt_remove_main_flag_directory_ignore_d, 0x1, &flag_out);
+        remove_print_warning_file_reason(&main->program.warning, path, kt_remove_print_reason_stat_fail_s);
+
+        return flag_out;
+      }
+    }
 
     if (macro_f_file_type_is_directory(statistics.st_mode)) {
       flag_out |= kt_remove_flag_file_operate_directory_d;
+
+      if (!recurse) {
+        memcpy(&main->cache.statistics, &statistics, sizeof(struct stat));
+      }
     }
 
-    kt_remove_preprocess_file_type(main, path, macro_f_file_type_is_fifo(statistics.st_mode), f_file_type_name_fifo_s, kt_remove_main_flag_fifo_d, kt_remove_main_flag_fifo_ignore_d, 0x1, &flag_out);
+    // Directories get pre-processed before recursion to prevent unnecessary recursion but the pre-process again happens after recursion to perform actual operations because the child paths must be all be removed before the directory.
+    simulate = (main->setting.flag & kt_remove_main_flag_simulate_d)
+      ? (flag_out & kt_remove_flag_file_operate_directory_d)
+        ? recurse
+          ? kt_remove_flag_simulate_directory_recurse_d
+          : kt_remove_flag_simulate_directory_d
+        : kt_remove_flag_simulate_directory_not_d
+      : kt_remove_flag_simulate_none_d;
+
+    kt_remove_print_simulate_operate_file(&main->program.output, simulate, path, flag_operate);
 
-    kt_remove_preprocess_file_type(main, path, macro_f_file_type_is_link(statistics.st_mode), f_file_type_name_link_s, kt_remove_main_flag_link_d, kt_remove_main_flag_link_ignore_d, 0x1, &flag_out);
+    kt_remove_print_simulate_operate_file_exists(&main->program.output, simulate, path, flag_out);
 
-    kt_remove_preprocess_file_type(main, path, macro_f_file_type_is_regular(statistics.st_mode), f_file_type_name_regular_s, kt_remove_main_flag_regular_d, kt_remove_main_flag_regular_ignore_d, 0x3, &flag_out);
+    kt_remove_preprocess_file_type(main, kt_remove_flag_simulate_is_a_d | simulate, path, macro_f_file_type_is_block(statistics.st_mode), f_file_type_name_block_s, kt_remove_main_flag_block_d, kt_remove_main_flag_block_ignore_d, &flag_out);
 
-    kt_remove_preprocess_file_type(main, path, macro_f_file_type_is_socket(statistics.st_mode), f_file_type_name_socket_s, kt_remove_main_flag_socket_d, kt_remove_main_flag_socket_ignore_d, 0x1, &flag_out);
+    kt_remove_preprocess_file_type(main, kt_remove_flag_simulate_is_a_d | simulate, path, macro_f_file_type_is_character(statistics.st_mode), f_file_type_name_character_s, kt_remove_main_flag_character_d, kt_remove_main_flag_character_ignore_d, &flag_out);
 
-    kt_remove_preprocess_file_type(main, path, macro_f_file_type_is_unknown(statistics.st_mode), f_file_type_name_unknown_s, kt_remove_main_flag_unknown_d, kt_remove_main_flag_unknown_ignore_d, 0x0, &flag_out);
+    kt_remove_preprocess_file_type(main, kt_remove_flag_simulate_is_a_d | simulate, path, macro_f_file_type_is_directory(statistics.st_mode), f_file_type_name_directory_s, kt_remove_main_flag_directory_d, kt_remove_main_flag_directory_ignore_d, &flag_out);
 
-    if (!(main->setting.flag & kt_remove_main_flag_simulate_d) && (flag_out & kt_remove_flag_file_operate_remove_fail_d)) return flag_out;
+    kt_remove_preprocess_file_type(main, kt_remove_flag_simulate_is_a_d | simulate, path, macro_f_file_type_is_fifo(statistics.st_mode), f_file_type_name_fifo_s, kt_remove_main_flag_fifo_d, kt_remove_main_flag_fifo_ignore_d, &flag_out);
+
+    kt_remove_preprocess_file_type(main, kt_remove_flag_simulate_is_a_d | simulate, path, macro_f_file_type_is_link(statistics.st_mode), f_file_type_name_link_s, kt_remove_main_flag_link_d, kt_remove_main_flag_link_ignore_d, &flag_out);
+
+    kt_remove_preprocess_file_type(main, kt_remove_flag_simulate_is_a_file_d | simulate, path, macro_f_file_type_is_regular(statistics.st_mode), f_file_type_name_regular_s, kt_remove_main_flag_regular_d, kt_remove_main_flag_regular_ignore_d, &flag_out);
+
+    kt_remove_preprocess_file_type(main, kt_remove_flag_simulate_is_a_d | simulate, path, macro_f_file_type_is_socket(statistics.st_mode), f_file_type_name_socket_s, kt_remove_main_flag_socket_d, kt_remove_main_flag_socket_ignore_d, &flag_out);
+
+    kt_remove_preprocess_file_type(main, simulate, path, macro_f_file_type_is_unknown(statistics.st_mode), f_file_type_name_unknown_s, kt_remove_main_flag_unknown_d, kt_remove_main_flag_unknown_ignore_d, &flag_out);
+
+    if (!simulate && (flag_out & kt_remove_flag_file_operate_remove_fail_d)) return flag_out;
 
     if (main->setting.flag & kt_remove_main_flag_user_d) {
       for (i = 0; i < main->setting.users.used; ++i) {
@@ -113,7 +136,9 @@ extern "C" {
         if (statistics.st_uid == (uid_t) main->setting.users.array[i]) break;
       } // for
 
-      kt_remove_print_simulate_operate_id(&main->program.output, (f_number_unsigned_t) statistics.st_uid, F_true);
+      if (simulate & ~0x10) {
+        kt_remove_print_simulate_operate_id(&main->program.output, simulate, (f_number_unsigned_t) statistics.st_uid, F_true);
+      }
 
       if (i < main->setting.users.used) {
         flag_out |= kt_remove_flag_file_operate_remove_d;
@@ -121,7 +146,7 @@ extern "C" {
     }
 
     if (main->setting.flag & kt_remove_main_flag_same_d) {
-      kt_remove_print_simulate_operate_boolean(&main->program.output, kt_remove_same_s, statistics.st_uid == geteuid());
+      kt_remove_print_simulate_operate_boolean(&main->program.output, simulate, kt_remove_same_s, statistics.st_uid == geteuid());
 
       if (statistics.st_uid == geteuid()) {
         flag_out |= kt_remove_flag_file_operate_remove_d;
@@ -129,7 +154,7 @@ extern "C" {
     }
 
     if (main->setting.flag & kt_remove_main_flag_different_d) {
-      kt_remove_print_simulate_operate_boolean(&main->program.output, kt_remove_different_s, statistics.st_uid != geteuid());
+      kt_remove_print_simulate_operate_boolean(&main->program.output, simulate, kt_remove_different_s, statistics.st_uid != geteuid());
 
       if (statistics.st_uid != geteuid()) {
         flag_out |= kt_remove_flag_file_operate_remove_d;
@@ -143,7 +168,7 @@ extern "C" {
         if (statistics.st_gid == (gid_t) main->setting.groups.array[i]) break;
       } // for
 
-      kt_remove_print_simulate_operate_id(&main->program.output, (f_number_unsigned_t) statistics.st_gid, F_false);
+      kt_remove_print_simulate_operate_id(&main->program.output, simulate, (f_number_unsigned_t) statistics.st_gid, F_false);
 
       if (i < main->setting.groups.used) {
         flag_out |= kt_remove_flag_file_operate_remove_d;
@@ -167,7 +192,7 @@ extern "C" {
         kt_remove_flag_mode_not_d,
       };
 
-      kt_remove_print_simulate_operate_mode(&main->program.output, (f_number_unsigned_t) mode, f_string_empty_s);
+      kt_remove_print_simulate_operate_mode(&main->program.output, simulate, (f_number_unsigned_t) mode, f_string_empty_s);
 
       for (i = 0; i < main->setting.modes.used; ++i) {
 
@@ -191,7 +216,7 @@ extern "C" {
         for (uint8_t j = 0; j < 4; ++j) {
 
           if (main->setting.modes.array[i].type == types[j]) {
-            kt_remove_print_simulate_operate_mode(&main->program.output, (f_number_unsigned_t) main->setting.modes.array[i].mode, modes[j]);
+            kt_remove_print_simulate_operate_mode(&main->program.output, simulate, (f_number_unsigned_t) main->setting.modes.array[i].mode, modes[j]);
 
             break;
           }
@@ -202,7 +227,7 @@ extern "C" {
     }
 
     if (main->setting.flag & kt_remove_main_flag_accessed_changed_updated_d) {
-      kt_remove_preprocess_file_dates(main, path, flag_operate, statistics);
+      kt_remove_preprocess_file_dates(main, simulate, path, flag_operate, statistics);
       if (F_status_is_error(main->setting.state.status)) return flag_out;
 
       if (main->setting.state.status == F_yes) {
@@ -215,7 +240,7 @@ extern "C" {
       if (F_status_is_error(main->setting.state.status)) return flag_out;
 
       if (main->setting.state.status == F_true || main->setting.state.status == F_false) {
-        kt_remove_print_simulate_operate_boolean(&main->program.output, kt_remove_empty_s, main->setting.state.status);
+        kt_remove_print_simulate_operate_boolean(&main->program.output, simulate, kt_remove_empty_s, main->setting.state.status);
 
         if (main->setting.state.status == F_true) {
           flag_out |= kt_remove_flag_file_operate_empty_d;
@@ -254,29 +279,29 @@ extern "C" {
     }
 
     if (flag_out & kt_remove_flag_file_operate_directory_d) {
-      kt_remove_print_simulate_operate_boolean(&main->program.output, kt_remove_recurse_s, (main->setting.flag & kt_remove_main_flag_recurse_d) && !(flag_operate & kt_remove_flag_file_operate_parent_d));
+      kt_remove_print_simulate_operate_boolean(&main->program.output, simulate, kt_remove_recurse_s, (main->setting.flag & kt_remove_main_flag_recurse_d) && !(flag_operate & kt_remove_flag_file_operate_parent_d));
     }
 
     if (main->setting.flag & kt_remove_main_flag_tree_d) {
-      kt_remove_print_simulate_operate_boolean(&main->program.output, kt_remove_parent_s, flag_operate & kt_remove_flag_file_operate_parent_d);
+      kt_remove_print_simulate_operate_boolean(&main->program.output, simulate, kt_remove_parent_s, flag_operate & kt_remove_flag_file_operate_parent_d);
     }
 
     if (main->setting.flag & kt_remove_main_flag_prompt_all_d) {
       if (main->setting.flag & (kt_remove_main_flag_prompt_each_d | kt_remove_main_flag_prompt_never_d)) {
-        kt_remove_print_simulate_operate_boolean(&main->program.output, kt_remove_prompt_s, main->setting.flag & kt_remove_main_flag_prompt_each_d);
+        kt_remove_print_simulate_operate_boolean(&main->program.output, simulate, kt_remove_prompt_s, main->setting.flag & kt_remove_main_flag_prompt_each_d);
       }
       else if (main->setting.flag & kt_remove_main_flag_prompt_follow_d) {
-        kt_remove_print_simulate_operate_boolean(&main->program.output, kt_remove_prompt_s, (main->setting.flag & kt_remove_main_flag_follow_d) && (flag_out & kt_remove_flag_file_operate_link_d));
+        kt_remove_print_simulate_operate_boolean(&main->program.output, simulate, kt_remove_prompt_s, (main->setting.flag & kt_remove_main_flag_follow_d) && (flag_out & kt_remove_flag_file_operate_link_d));
       }
       else if (main->setting.flag & kt_remove_main_flag_prompt_once_d) {
-        kt_remove_print_simulate_operate_boolean(&main->program.output, kt_remove_prompt_s, !(main->setting.prompt));
+        kt_remove_print_simulate_operate_boolean(&main->program.output, simulate, kt_remove_prompt_s, !(main->setting.prompt));
       }
     }
 
-    kt_remove_print_simulate_operate_boolean(&main->program.output, kt_remove_remove_s, kt_remove_operate_shall_remove(flag_out));
+    kt_remove_print_simulate_operate_boolean(&main->program.output, simulate, kt_remove_remove_s, kt_remove_operate_shall_remove(flag_out));
 
     // Only apply tree operations on non-child paths when the tree flag is set.
-    if ((main->setting.flag & kt_remove_main_flag_tree_d) && !(flag_operate & kt_remove_flag_file_operate_child_d)) {
+    if ((main->setting.flag & kt_remove_main_flag_tree_d) && !(flag_operate & kt_remove_flag_file_operate_child_d) && !recurse) {
       f_range_t range = macro_f_range_t_initialize_2(path.used);
 
       if (range.stop > range.start) {
@@ -328,7 +353,7 @@ extern "C" {
 #endif // _di_kt_remove_preprocess_file_
 
 #ifndef _di_kt_remove_preprocess_file_dates_
-  void kt_remove_preprocess_file_dates(kt_remove_main_t * const main, const f_string_static_t path, const uint32_t flag_operate, const struct stat statistics) {
+  void kt_remove_preprocess_file_dates(kt_remove_main_t * const main, const uint8_t simulate, const f_string_static_t path, const uint32_t flag_operate, const struct stat statistics) {
 
     if (!main) return;
 
@@ -574,7 +599,7 @@ extern "C" {
         }
 
         if (name_type.used) {
-          kt_remove_print_simulate_operate_date(&main->program.output, names[i], result, times[i], dates[i]->array[j], name_type);
+          kt_remove_print_simulate_operate_date(&main->program.output, simulate, names[i], result, times[i], dates[i]->array[j], name_type);
 
           break;
         }
@@ -586,7 +611,7 @@ extern "C" {
 #endif // _di_kt_remove_preprocess_file_dates_
 
 #ifndef _di_kt_remove_preprocess_file_type_
-  void kt_remove_preprocess_file_type(kt_remove_main_t * const main, const f_string_static_t path, const bool is, f_string_static_t name, const uint64_t type, const uint64_t ignore, const uint8_t code, uint32_t * const flag_out) {
+  void kt_remove_preprocess_file_type(kt_remove_main_t * const main, const uint8_t simulate, const f_string_static_t path, const bool is, f_string_static_t name, const uint64_t type, const uint64_t ignore, uint32_t * const flag_out) {
 
     if (!main || !flag_out) return;
 
@@ -595,14 +620,14 @@ extern "C" {
         *flag_out |= kt_remove_flag_file_operate_remove_d;
       }
       else if (main->setting.flag & kt_remove_main_flag_option_type_d) {
-        kt_remove_print_error_file_is_a(&main->program.error, path, name, code);
+        kt_remove_print_error_file_is_a(&main->program.error, path, name, simulate & kt_remove_flag_simulate_is_a_file_d);
 
         *flag_out |= kt_remove_flag_file_operate_remove_fail_d;
       }
     }
 
     if (is || (main->setting.flag & type) && !(main->setting.flag & ignore)) {
-      kt_remove_print_simulate_operate_boolean(&main->program.output, name, is);
+      kt_remove_print_simulate_operate_boolean(&main->program.output, simulate & ~kt_remove_flag_simulate_is_a_file_d, name, is);
     }
   }
 #endif // _di_kt_remove_preprocess_file_type_
index cdf4161b0a6c3714842dc9a1f8e8c280ed3f2025..dcac5468e7d06b11c986ee7951e9ff8b3e7e781d 100644 (file)
@@ -33,6 +33,10 @@ extern "C" {
  *   The path to the file to operate on.
  * @param flag_operate
  *   The operate file specific flags from kt_remove_flag_file_operate_*_e.
+ * @param recurse
+ *   If F_true as 0x1, then this function is being called during directory recursion.
+ *   If F_true as 0x2, then this funtion is being called during directory recursion and it represents the parent directory being recursed.
+ *   If F_false, then this function is being called outside of directory recursion.
  *
  * @return
  *   The resulting flags determined by the pre-process.
@@ -44,7 +48,7 @@ extern "C" {
  * @see kt_remove_preprocess_file_dates()
  */
 #ifndef _di_kt_remove_preprocess_file_
-  extern uint16_t kt_remove_preprocess_file(kt_remove_main_t * const main, const f_string_static_t path, const uint32_t flag_operate);
+  extern uint16_t kt_remove_preprocess_file(kt_remove_main_t * const main, const f_string_static_t path, const uint32_t flag_operate, const uint8_t recurse);
 #endif // _di_kt_remove_preprocess_file_
 
 /**
@@ -59,6 +63,9 @@ extern "C" {
  *     F_yes on date matched.
  *     F_no on no matches.
  *     F_parameter (with error bit) if a parameter is invalid.
+ * @param simulate
+ *   When non-zero, then this designates that the simulate printing should happen.
+ *   When kt_remove_flag_simulate_directory_d, the printing is not performed.
  * @param path
  *   The path to the file to operate on.
  * @param flag_operate
@@ -67,7 +74,7 @@ extern "C" {
  *   The already loaded file statistics.
  */
 #ifndef _di_kt_remove_preprocess_file_dates_
-  extern void kt_remove_preprocess_file_dates(kt_remove_main_t * const main, const f_string_static_t path, const uint32_t flag_operate, const struct stat statistics);
+  extern void kt_remove_preprocess_file_dates(kt_remove_main_t * const main, const uint8_t simulate, const f_string_static_t path, const uint32_t flag_operate, const struct stat statistics);
 #endif // _di_kt_remove_preprocess_file_dates_
 
 /**
@@ -82,6 +89,13 @@ extern "C" {
  *     F_yes on date matched.
  *     F_no on no matches.
  *     F_parameter (with error bit) if a parameter is invalid.
+ * @param simulate
+ *   Values 0x1 and 0x2 are intended to be passed to kt_remove_print_error_file_is_a() as needed.
+ *   Other values:
+ *     - 0x4:  Simulate, non-directory.
+ *     - 0x8:  Simulate directory, recurse.
+ *     - 0x10: Simulate directory, not recurse.
+ *     - 0x1c: Any of these bits set (0x4, 0x8, and 0x10), then simulate is enabled.
  * @param path
  *   The path to the file to operate on.
  * @param is
@@ -93,15 +107,13 @@ extern "C" {
  *   A flag from the kt_remove_main_flag_*_d representing the file type.
  * @param ignore
  *   A flag from the kt_remove_main_flag_*_ignore_d representing the file type ignore flag.
- * @param code
- *   A code intended to be passed to kt_remove_print_error_file_is_a() as needed.
  * @param flag_out
  *   The return flag to modify if needed.
  *
  *   Must not be NULL.
  */
 #ifndef _di_kt_remove_preprocess_file_type_
-  extern void kt_remove_preprocess_file_type(kt_remove_main_t * const main, const f_string_static_t path, const bool is, f_string_static_t name, const uint64_t type, const uint64_t ignore, const uint8_t code, uint32_t * const flag_out);
+  extern void kt_remove_preprocess_file_type(kt_remove_main_t * const main, const uint8_t simulate, const f_string_static_t path, const bool is, f_string_static_t name, const uint64_t type, const uint64_t ignore, uint32_t * const flag_out);
 #endif // _di_kt_remove_preprocess_file_type_
 
 #ifdef __cplusplus
index abfe5e198c5a37096e18b3abe18f1991e02e2d27..94c57ed6f33dc553a86d7dfb2d5282e1236eb876 100644 (file)
@@ -34,13 +34,13 @@ extern "C" {
     fl_print_format("%[%Q%]", print->to, print->set->notable, path, print->set->notable);
     fl_print_format("%[', is ", print->to, print->set->error);
 
-    if (code & 0x1) {
+    if (code & kt_remove_flag_simulate_is_a_d) {
       fl_print_format("a ", print->to);
     }
 
     fl_print_format("%Q", print->to, is);
 
-    if (code & 0x2) {
+    if (code & kt_remove_flag_simulate_is_file_d) {
       fl_print_format(" file", print->to);
     }
 
index 1a334bb889f2647862bcd0d5e42f8e43063eee92..c20e5ba06787cef2370a5557940b888b658e2f3d 100644 (file)
@@ -86,8 +86,9 @@ extern "C" {
  * @param is
  *   Designate what the file is.
  * @param code
- *   Set to 0x1 to print an ' a' before the 'is' parameter.
- *   Set to 0x2 to print ' file' after the 'is' parameter.
+ *   The code from the "is" parts of kt_remove_flag_simulate_is_*_d:
+ *     - a:    Print an ' a' before the 'is' parameter.
+ *     - file: Print ' file' after the 'is' parameter.
  *
  * @return
  *   F_okay on success.
index 537c999466ed41eb328018b3e26333fd86a1a4c0..df996fa106000d3d43e78ef548ac7d308ea8d45e 100644 (file)
@@ -21,8 +21,6 @@ extern "C" {
       fl_print_format("  %Q%r", print->to, main->setting.files.array[i], f_string_eol_s);
     } // for
 
-    f_print_dynamic(f_string_eol_s, print->to);
-
     f_file_stream_unlock(print->to);
 
     return F_okay;
@@ -30,13 +28,10 @@ extern "C" {
 #endif // _di_kt_remove_print_simulate_operate_
 
 #ifndef _di_kt_remove_print_simulate_operate_boolean_
-  f_status_t kt_remove_print_simulate_operate_boolean(fl_print_t * const print, const f_string_static_t name, const bool yes) {
-
-    if (!print || !print->custom) return F_status_set_error(F_output_not);
+  f_status_t kt_remove_print_simulate_operate_boolean(fl_print_t * const print, const uint8_t simulate, const f_string_static_t name, const bool yes) {
 
-    kt_remove_main_t * const main = (kt_remove_main_t *) print->custom;
-
-    if (!(main->setting.flag & kt_remove_main_flag_simulate_d)) return F_output_not;
+    if (!print) return F_status_set_error(F_output_not);
+    if (!simulate || (simulate & kt_remove_flag_simulate_directory_d)) return F_output_not;
 
     fll_print_format("  %r %r%r", print->to, name, yes ? kt_remove_yes_s : kt_remove_no_s, f_string_eol_s);
 
@@ -45,13 +40,10 @@ extern "C" {
 #endif // _di_kt_remove_print_simulate_operate_boolean_
 
 #ifndef _di_kt_remove_print_simulate_operate_date_
-  f_status_t kt_remove_print_simulate_operate_date(fl_print_t * const print, const f_string_static_t name, const bool yes, const f_time_spec_t time, const kt_remove_date_t date, const f_string_static_t type) {
+  f_status_t kt_remove_print_simulate_operate_date(fl_print_t * const print, const uint8_t simulate, const f_string_static_t name, const bool yes, const f_time_spec_t time, const kt_remove_date_t date, const f_string_static_t type) {
 
-    if (!print || !print->custom) return F_status_set_error(F_output_not);
-
-    kt_remove_main_t * const main = (kt_remove_main_t *) print->custom;
-
-    if (!(main->setting.flag & kt_remove_main_flag_simulate_d)) return F_output_not;
+    if (!print) return F_status_set_error(F_output_not);
+    if (!simulate || (simulate & kt_remove_flag_simulate_directory_d)) return F_output_not;
 
     const f_number_unsigned_t match_year = kt_remove_time_year_unix_epoch_d + (time.tv_sec / kt_remove_time_seconds_in_year_d);
     const f_number_unsigned_t match_second = time.tv_sec % kt_remove_time_seconds_in_year_d;
@@ -72,9 +64,10 @@ extern "C" {
 #endif // _di_kt_remove_print_simulate_operate_date_
 
 #ifndef _di_kt_remove_print_simulate_operate_file_
-  f_status_t kt_remove_print_simulate_operate_file(fl_print_t * const print, const f_string_static_t path, const uint32_t flag) {
+  f_status_t kt_remove_print_simulate_operate_file(fl_print_t * const print, const uint8_t simulate, const f_string_static_t path, const uint32_t flag) {
 
     if (!print || !print->custom) return F_status_set_error(F_output_not);
+    if (!simulate || (simulate & kt_remove_flag_simulate_directory_d)) return F_output_not;
 
     kt_remove_main_t * const main = (kt_remove_main_t *) print->custom;
 
@@ -97,9 +90,10 @@ extern "C" {
 #endif // _di_kt_remove_print_simulate_operate_file_
 
 #ifndef _di_kt_remove_print_simulate_operate_file_exists_
-  f_status_t kt_remove_print_simulate_operate_file_exists(fl_print_t * const print, const f_string_static_t path, const uint32_t flag) {
+  f_status_t kt_remove_print_simulate_operate_file_exists(fl_print_t * const print, const uint8_t simulate, const f_string_static_t path, const uint32_t flag) {
 
     if (!print || !print->custom) return F_status_set_error(F_output_not);
+    if (!simulate || (simulate & kt_remove_flag_simulate_directory_d)) return F_output_not;
 
     kt_remove_main_t * const main = (kt_remove_main_t *) print->custom;
 
@@ -137,13 +131,10 @@ extern "C" {
 #endif // _di_kt_remove_print_simulate_operate_file_exists_
 
 #ifndef _di_kt_remove_print_simulate_operate_id_
-  f_status_t kt_remove_print_simulate_operate_id(fl_print_t * const print, const f_number_unsigned_t id, const bool is_user) {
+  f_status_t kt_remove_print_simulate_operate_id(fl_print_t * const print, const uint8_t simulate, const f_number_unsigned_t id, const bool is_user) {
 
-    if (!print || !print->custom) return F_status_set_error(F_output_not);
-
-    kt_remove_main_t * const main = (kt_remove_main_t *) print->custom;
-
-    if (!(main->setting.flag & kt_remove_main_flag_simulate_d)) return F_output_not;
+    if (!print) return F_status_set_error(F_output_not);
+    if (!simulate || (simulate & kt_remove_flag_simulate_directory_d)) return F_output_not;
 
     fll_print_format("  %r %un%r", print->to, is_user ? kt_remove_user_s : kt_remove_group_s, id, f_string_eol_s);
 
@@ -152,13 +143,10 @@ extern "C" {
 #endif // _di_kt_remove_print_simulate_operate_id_
 
 #ifndef _di_kt_remove_print_simulate_operate_mode_
-  f_status_t kt_remove_print_simulate_operate_mode(fl_print_t * const print, const f_number_unsigned_t mode, const f_string_static_t match) {
+  f_status_t kt_remove_print_simulate_operate_mode(fl_print_t * const print, const uint8_t simulate, const f_number_unsigned_t mode, const f_string_static_t match) {
 
-    if (!print || !print->custom) return F_status_set_error(F_output_not);
-
-    kt_remove_main_t * const main = (kt_remove_main_t *) print->custom;
-
-    if (!(main->setting.flag & kt_remove_main_flag_simulate_d)) return F_output_not;
+    if (!print) return F_status_set_error(F_output_not);
+    if (!simulate || (simulate & kt_remove_flag_simulate_directory_d)) return F_output_not;
 
     if (match.used) {
       fll_print_format("  mode_matched %Q %@03un%r", print->to, match, mode, f_string_eol_s);
index b0e2bd45c1ec6ae00f4ba60c3b066f4ff74cc926..5178fd4ee3c5078c548b50d9c272e5b6c3e3d932 100644 (file)
@@ -53,6 +53,9 @@ extern "C" {
  *   Must not be NULL.
  *
  *   This does not alter print.custom.setting.state.status.
+ * @param simulate
+ *   When non-zero, then this designates that the simulate printing should happen.
+ *   When kt_remove_flag_simulate_directory_d, the printing is not performed.
  * @param name
  *   The name to be associated with the boolean value.
  * @param yes
@@ -66,7 +69,7 @@ extern "C" {
  *   F_output_not (with error bit) if setting is NULL.
  */
 #ifndef _di_kt_remove_print_simulate_operate_boolean_
-  extern f_status_t kt_remove_print_simulate_operate_boolean(fl_print_t * const print, const f_string_static_t name, const bool yes);
+  extern f_status_t kt_remove_print_simulate_operate_boolean(fl_print_t * const print, const uint8_t simulate, const f_string_static_t name, const bool yes);
 #endif // _di_kt_remove_print_simulate_operate_boolean_
 
 /**
@@ -82,6 +85,9 @@ extern "C" {
  *   Must not be NULL.
  *
  *   This does not alter print.custom.setting.state.status.
+ * @param simulate
+ *   When non-zero, then this designates that the simulate printing should happen.
+ *   When kt_remove_flag_simulate_directory_d, the printing is not performed.
  * @param name
  *   The name to be associated with the boolean value.
  * @param yes
@@ -101,7 +107,7 @@ extern "C" {
  *   F_output_not (with error bit) if setting is NULL.
  */
 #ifndef _di_kt_remove_print_simulate_operate_date_
-  extern f_status_t kt_remove_print_simulate_operate_date(fl_print_t * const print, const f_string_static_t name, const bool yes, const f_time_spec_t time, const kt_remove_date_t date, const f_string_static_t type);
+  extern f_status_t kt_remove_print_simulate_operate_date(fl_print_t * const print, const uint8_t simulate, const f_string_static_t name, const bool yes, const f_time_spec_t time, const kt_remove_date_t date, const f_string_static_t type);
 #endif // _di_kt_remove_print_simulate_operate_date_
 
 /**
@@ -117,6 +123,9 @@ extern "C" {
  *   Must not be NULL.
  *
  *   This does not alter print.custom.setting.state.status.
+ * @param simulate
+ *   When non-zero, then this designates that the simulate printing should happen.
+ *   When kt_remove_flag_simulate_directory_d, the printing is not performed.
  * @param path
  *   The path to the file to operate on.
  * @param flag
@@ -130,7 +139,7 @@ extern "C" {
  *   F_output_not (with error bit) if setting is NULL.
  */
 #ifndef _di_kt_remove_print_simulate_operate_file_
-  extern f_status_t kt_remove_print_simulate_operate_file(fl_print_t * const print, const f_string_static_t path, const uint32_t flag);
+  extern f_status_t kt_remove_print_simulate_operate_file(fl_print_t * const print, const uint8_t simulate, const f_string_static_t path, const uint32_t flag);
 #endif // _di_kt_remove_print_simulate_operate_file_
 
 /**
@@ -146,6 +155,9 @@ extern "C" {
  *   Must not be NULL.
  *
  *   This does not alter print.custom.setting.state.status.
+ * @param simulate
+ *   When non-zero, then this designates that the simulate printing should happen.
+ *   When kt_remove_flag_simulate_directory_d, the printing is not performed.
  * @param path
  *   The path to the file to operate on.
  * @param flag
@@ -159,7 +171,7 @@ extern "C" {
  *   F_output_not (with error bit) if setting is NULL.
  */
 #ifndef _di_kt_remove_print_simulate_operate_file_exists_
-  extern f_status_t kt_remove_print_simulate_operate_file_exists(fl_print_t * const print, const f_string_static_t path, const uint32_t flag);
+  extern f_status_t kt_remove_print_simulate_operate_file_exists(fl_print_t * const print, const uint8_t simulate, const f_string_static_t path, const uint32_t flag);
 #endif // _di_kt_remove_print_simulate_operate_file_exists_
 
 /**
@@ -175,6 +187,9 @@ extern "C" {
  *   Must not be NULL.
  *
  *   This does not alter print.custom.setting.state.status.
+ * @param simulate
+ *   When non-zero, then this designates that the simulate printing should happen.
+ *   When kt_remove_flag_simulate_directory_d, the printing is not performed.
  * @param id
  *   The user or group ID.
  * @param is_user
@@ -188,7 +203,7 @@ extern "C" {
  *   F_output_not (with error bit) if setting is NULL.
  */
 #ifndef _di_kt_remove_print_simulate_operate_id_
-  extern f_status_t kt_remove_print_simulate_operate_id(fl_print_t * const print, const f_number_unsigned_t id, const bool is_user);
+  extern f_status_t kt_remove_print_simulate_operate_id(fl_print_t * const print, const uint8_t simulate, const f_number_unsigned_t id, const bool is_user);
 #endif // _di_kt_remove_print_simulate_operate_id_
 
 /**
@@ -204,6 +219,9 @@ extern "C" {
  *   Must not be NULL.
  *
  *   This does not alter print.custom.setting.state.status.
+ * @param simulate
+ *   When non-zero, then this designates that the simulate printing should happen.
+ *   When kt_remove_flag_simulate_directory_d, the printing is not performed.
  * @param mode
  *   The mode of the file.
  * @param match
@@ -217,7 +235,7 @@ extern "C" {
  *   F_output_not (with error bit) if setting is NULL.
  */
 #ifndef _di_kt_remove_print_simulate_operate_mode_
-  extern f_status_t kt_remove_print_simulate_operate_mode(fl_print_t * const print, const f_number_unsigned_t mode, const f_string_static_t match);
+  extern f_status_t kt_remove_print_simulate_operate_mode(fl_print_t * const print, const uint8_t simulate, const f_number_unsigned_t mode, const f_string_static_t match);
 #endif // _di_kt_remove_print_simulate_operate_mode_
 
 #ifdef __cplusplus
index 5b1750e8f749d528f0e9e4408d2ae90962379209..cd21383639c375544b636642b4d005528df0ea8f 100644 (file)
@@ -65,7 +65,7 @@ extern "C" {
 
     for (; i < main->setting.files.used; ++i) {
 
-      main->setting.state.status = kt_remove_operate_file(main, main->setting.files.array[i]);
+      main->setting.state.status = kt_remove_operate_file(main, main->setting.files.array[i], F_false);
 
       if ((main->setting.flag & kt_remove_main_flag_simulate_d) && i + 1 < main->setting.files.used && (F_status_is_error_not(main->setting.state.status) || F_status_set_fine(main->setting.state.status) == F_interrupt)) {
         f_print_dynamic(f_string_eol_s, main->program.output.to);
index 3a110db8d922efa487d6ec633862ba72fa005804..9321cb47c09b6ebc76e9a4ec1cea605a41008bf0 100644 (file)
@@ -139,10 +139,9 @@ void test__kt_remove__date_accessed__date_works(void **state) {
 
           if (time_spec_removes[date]) {
             if (macro_f_file_type_is_directory(stats[type].st_mode)) {
-              will_return(__wrap_fl_directory_do, 1);
-              will_return(__wrap_fl_directory_do, &target);
-              will_return(__wrap_fl_directory_do, &target);
-              will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_directory_e | f_directory_recurse_do_flag_top_after_e);
+              will_return(__wrap_fl_directory_do, 0);
+              will_return(__wrap_fl_directory_do, F_okay);
+
               will_return(__wrap_f_directory_remove, F_okay);
             }
             else {
@@ -294,10 +293,9 @@ void test__kt_remove__date_accessed__now_works(void **state) {
 
         if (time_spec_removes[date]) {
           if (macro_f_file_type_is_directory(stats[type].st_mode)) {
-            will_return(__wrap_fl_directory_do, 1);
-            will_return(__wrap_fl_directory_do, &target);
-            will_return(__wrap_fl_directory_do, &target);
-            will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_directory_e | f_directory_recurse_do_flag_top_after_e);
+            will_return(__wrap_fl_directory_do, 0);
+            will_return(__wrap_fl_directory_do, F_okay);
+
             will_return(__wrap_f_directory_remove, F_okay);
           }
           else {
@@ -448,10 +446,9 @@ void test__kt_remove__date_accessed__today_works(void **state) {
 
         if (time_spec_removes[date]) {
           if (macro_f_file_type_is_directory(stats[type].st_mode)) {
-            will_return(__wrap_fl_directory_do, 1);
-            will_return(__wrap_fl_directory_do, &target);
-            will_return(__wrap_fl_directory_do, &target);
-            will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_directory_e | f_directory_recurse_do_flag_top_after_e);
+            will_return(__wrap_fl_directory_do, 0);
+            will_return(__wrap_fl_directory_do, F_okay);
+
             will_return(__wrap_f_directory_remove, F_okay);
           }
           else {
@@ -602,10 +599,9 @@ void test__kt_remove__date_accessed__tomorrow_works(void **state) {
 
         if (time_spec_removes[date]) {
           if (macro_f_file_type_is_directory(stats[type].st_mode)) {
-            will_return(__wrap_fl_directory_do, 1);
-            will_return(__wrap_fl_directory_do, &target);
-            will_return(__wrap_fl_directory_do, &target);
-            will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_directory_e | f_directory_recurse_do_flag_top_after_e);
+            will_return(__wrap_fl_directory_do, 0);
+            will_return(__wrap_fl_directory_do, F_okay);
+
             will_return(__wrap_f_directory_remove, F_okay);
           }
           else {
@@ -756,10 +752,9 @@ void test__kt_remove__date_accessed__yesterday_works(void **state) {
 
         if (time_spec_removes[date]) {
           if (macro_f_file_type_is_directory(stats[type].st_mode)) {
-            will_return(__wrap_fl_directory_do, 1);
-            will_return(__wrap_fl_directory_do, &target);
-            will_return(__wrap_fl_directory_do, &target);
-            will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_directory_e | f_directory_recurse_do_flag_top_after_e);
+            will_return(__wrap_fl_directory_do, 0);
+            will_return(__wrap_fl_directory_do, F_okay);
+
             will_return(__wrap_f_directory_remove, F_okay);
           }
           else {
index 3a8cb030956c1728ec386f03d77c110d8b362c0a..c3ebf0e6d1a56169e36df3de291297a526f917c3 100644 (file)
@@ -139,10 +139,9 @@ void test__kt_remove__date_changed__date_works(void **state) {
 
           if (time_spec_removes[date]) {
             if (macro_f_file_type_is_directory(stats[type].st_mode)) {
-              will_return(__wrap_fl_directory_do, 1);
-              will_return(__wrap_fl_directory_do, &target);
-              will_return(__wrap_fl_directory_do, &target);
-              will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_directory_e | f_directory_recurse_do_flag_top_after_e);
+            will_return(__wrap_fl_directory_do, 0);
+            will_return(__wrap_fl_directory_do, F_okay);
+
               will_return(__wrap_f_directory_remove, F_okay);
             }
             else {
@@ -294,10 +293,9 @@ void test__kt_remove__date_changed__now_works(void **state) {
 
         if (time_spec_removes[date]) {
           if (macro_f_file_type_is_directory(stats[type].st_mode)) {
-            will_return(__wrap_fl_directory_do, 1);
-            will_return(__wrap_fl_directory_do, &target);
-            will_return(__wrap_fl_directory_do, &target);
-            will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_directory_e | f_directory_recurse_do_flag_top_after_e);
+            will_return(__wrap_fl_directory_do, 0);
+            will_return(__wrap_fl_directory_do, F_okay);
+
             will_return(__wrap_f_directory_remove, F_okay);
           }
           else {
@@ -448,10 +446,9 @@ void test__kt_remove__date_changed__today_works(void **state) {
 
         if (time_spec_removes[date]) {
           if (macro_f_file_type_is_directory(stats[type].st_mode)) {
-            will_return(__wrap_fl_directory_do, 1);
-            will_return(__wrap_fl_directory_do, &target);
-            will_return(__wrap_fl_directory_do, &target);
-            will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_directory_e | f_directory_recurse_do_flag_top_after_e);
+            will_return(__wrap_fl_directory_do, 0);
+            will_return(__wrap_fl_directory_do, F_okay);
+
             will_return(__wrap_f_directory_remove, F_okay);
           }
           else {
@@ -602,10 +599,9 @@ void test__kt_remove__date_changed__tomorrow_works(void **state) {
 
         if (time_spec_removes[date]) {
           if (macro_f_file_type_is_directory(stats[type].st_mode)) {
-            will_return(__wrap_fl_directory_do, 1);
-            will_return(__wrap_fl_directory_do, &target);
-            will_return(__wrap_fl_directory_do, &target);
-            will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_directory_e | f_directory_recurse_do_flag_top_after_e);
+            will_return(__wrap_fl_directory_do, 0);
+            will_return(__wrap_fl_directory_do, F_okay);
+
             will_return(__wrap_f_directory_remove, F_okay);
           }
           else {
@@ -756,10 +752,9 @@ void test__kt_remove__date_changed__yesterday_works(void **state) {
 
         if (time_spec_removes[date]) {
           if (macro_f_file_type_is_directory(stats[type].st_mode)) {
-            will_return(__wrap_fl_directory_do, 1);
-            will_return(__wrap_fl_directory_do, &target);
-            will_return(__wrap_fl_directory_do, &target);
-            will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_directory_e | f_directory_recurse_do_flag_top_after_e);
+            will_return(__wrap_fl_directory_do, 0);
+            will_return(__wrap_fl_directory_do, F_okay);
+
             will_return(__wrap_f_directory_remove, F_okay);
           }
           else {
index 648be21ecbba41cf894a0b6c0f6cc5436a9dad44..e30749e0d8c2e66ab1235047ef9a4e741f35ddd6 100644 (file)
@@ -139,10 +139,9 @@ void test__kt_remove__date_updated__date_works(void **state) {
 
           if (time_spec_removes[date]) {
             if (macro_f_file_type_is_directory(stats[type].st_mode)) {
-              will_return(__wrap_fl_directory_do, 1);
-              will_return(__wrap_fl_directory_do, &target);
-              will_return(__wrap_fl_directory_do, &target);
-              will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_directory_e | f_directory_recurse_do_flag_top_after_e);
+            will_return(__wrap_fl_directory_do, 0);
+            will_return(__wrap_fl_directory_do, F_okay);
+
               will_return(__wrap_f_directory_remove, F_okay);
             }
             else {
@@ -294,10 +293,9 @@ void test__kt_remove__date_updated__now_works(void **state) {
 
         if (time_spec_removes[date]) {
           if (macro_f_file_type_is_directory(stats[type].st_mode)) {
-            will_return(__wrap_fl_directory_do, 1);
-            will_return(__wrap_fl_directory_do, &target);
-            will_return(__wrap_fl_directory_do, &target);
-            will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_directory_e | f_directory_recurse_do_flag_top_after_e);
+            will_return(__wrap_fl_directory_do, 0);
+            will_return(__wrap_fl_directory_do, F_okay);
+
             will_return(__wrap_f_directory_remove, F_okay);
           }
           else {
@@ -448,10 +446,9 @@ void test__kt_remove__date_updated__today_works(void **state) {
 
         if (time_spec_removes[date]) {
           if (macro_f_file_type_is_directory(stats[type].st_mode)) {
-            will_return(__wrap_fl_directory_do, 1);
-            will_return(__wrap_fl_directory_do, &target);
-            will_return(__wrap_fl_directory_do, &target);
-            will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_directory_e | f_directory_recurse_do_flag_top_after_e);
+            will_return(__wrap_fl_directory_do, 0);
+            will_return(__wrap_fl_directory_do, F_okay);
+
             will_return(__wrap_f_directory_remove, F_okay);
           }
           else {
@@ -602,10 +599,9 @@ void test__kt_remove__date_updated__tomorrow_works(void **state) {
 
         if (time_spec_removes[date]) {
           if (macro_f_file_type_is_directory(stats[type].st_mode)) {
-            will_return(__wrap_fl_directory_do, 1);
-            will_return(__wrap_fl_directory_do, &target);
-            will_return(__wrap_fl_directory_do, &target);
-            will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_directory_e | f_directory_recurse_do_flag_top_after_e);
+            will_return(__wrap_fl_directory_do, 0);
+            will_return(__wrap_fl_directory_do, F_okay);
+
             will_return(__wrap_f_directory_remove, F_okay);
           }
           else {
@@ -756,10 +752,9 @@ void test__kt_remove__date_updated__yesterday_works(void **state) {
 
         if (time_spec_removes[date]) {
           if (macro_f_file_type_is_directory(stats[type].st_mode)) {
-            will_return(__wrap_fl_directory_do, 1);
-            will_return(__wrap_fl_directory_do, &target);
-            will_return(__wrap_fl_directory_do, &target);
-            will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_directory_e | f_directory_recurse_do_flag_top_after_e);
+            will_return(__wrap_fl_directory_do, 0);
+            will_return(__wrap_fl_directory_do, F_okay);
+
             will_return(__wrap_f_directory_remove, F_okay);
           }
           else {
index faa1de4ff062767fd54ff246569769d25988b92f..db85a11b035cf746e8e63e7d0c3933c11f2b0eaa 100644 (file)
@@ -30,10 +30,8 @@ void test__kt_remove__directory_no_args__one_empty_exists_link(void **state) {
 
     // Directory processing.
     will_return(__wrap_f_directory_empty, F_true);
-    will_return(__wrap_fl_directory_do, 1);
-    will_return(__wrap_fl_directory_do, &file);
-    will_return(__wrap_fl_directory_do, &file);
-    will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_top_after_e);
+    will_return(__wrap_fl_directory_do, 0);
+    will_return(__wrap_fl_directory_do, F_okay);
 
     // This will fail if f_directory_remove() is not called, therefore success here means f_directory_remove has been called.
     will_return(__wrap_f_directory_remove, F_okay);
@@ -57,10 +55,8 @@ void test__kt_remove__directory_no_args__one_empty_exists_link(void **state) {
 
     // Directory processing.
     will_return(__wrap_f_directory_empty, F_true);
-    will_return(__wrap_fl_directory_do, 1);
-    will_return(__wrap_fl_directory_do, &file);
-    will_return(__wrap_fl_directory_do, &file);
-    will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_directory_e | f_directory_recurse_do_flag_top_after_e);
+    will_return(__wrap_fl_directory_do, 0);
+    will_return(__wrap_fl_directory_do, F_okay);
 
     // This will fail if f_directory_remove() is not called, therefore success here means f_directory_remove has been called.
     will_return(__wrap_f_directory_remove, F_okay);
@@ -84,10 +80,8 @@ void test__kt_remove__directory_no_args__one_empty_exists_link(void **state) {
 
     // Directory processing.
     will_return(__wrap_f_directory_empty, F_true);
-    will_return(__wrap_fl_directory_do, 1);
-    will_return(__wrap_fl_directory_do, &file);
-    will_return(__wrap_fl_directory_do, &file);
-    will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_directory_e | f_directory_recurse_do_flag_top_after_e);
+    will_return(__wrap_fl_directory_do, 0);
+    will_return(__wrap_fl_directory_do, F_okay);
 
     // This will fail if f_directory_remove() is not called, therefore success here means f_directory_remove has been called.
     will_return(__wrap_f_directory_remove, F_okay);
@@ -121,10 +115,8 @@ void test__kt_remove__directory_no_args__one_empty_exists_link_not(void **state)
 
     // Directory processing.
     will_return(__wrap_f_directory_empty, F_true);
-    will_return(__wrap_fl_directory_do, 1);
-    will_return(__wrap_fl_directory_do, &file);
-    will_return(__wrap_fl_directory_do, &file);
-    will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_directory_e | f_directory_recurse_do_flag_top_after_e);
+    will_return(__wrap_fl_directory_do, 0);
+    will_return(__wrap_fl_directory_do, F_okay);
 
     // This will fail if f_directory_remove() is not called, therefore success here means f_directory_remove has been called.
     will_return(__wrap_f_directory_remove, F_okay);
@@ -148,10 +140,8 @@ void test__kt_remove__directory_no_args__one_empty_exists_link_not(void **state)
 
     // Directory processing.
     will_return(__wrap_f_directory_empty, F_true);
-    will_return(__wrap_fl_directory_do, 1);
-    will_return(__wrap_fl_directory_do, &file);
-    will_return(__wrap_fl_directory_do, &file);
-    will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_directory_e | f_directory_recurse_do_flag_top_after_e);
+    will_return(__wrap_fl_directory_do, 0);
+    will_return(__wrap_fl_directory_do, F_okay);
 
     // This will fail if f_directory_remove() is not called, therefore success here means f_directory_remove has been called.
     will_return(__wrap_f_directory_remove, F_okay);
@@ -175,10 +165,8 @@ void test__kt_remove__directory_no_args__one_empty_exists_link_not(void **state)
 
     // Directory processing.
     will_return(__wrap_f_directory_empty, F_true);
-    will_return(__wrap_fl_directory_do, 1);
-    will_return(__wrap_fl_directory_do, &file);
-    will_return(__wrap_fl_directory_do, &file);
-    will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_directory_e | f_directory_recurse_do_flag_top_after_e);
+    will_return(__wrap_fl_directory_do, 0);
+    will_return(__wrap_fl_directory_do, F_okay);
 
     // This will fail if f_directory_remove() is not called, therefore success here means f_directory_remove has been called.
     will_return(__wrap_f_directory_remove, F_okay);
@@ -257,7 +245,14 @@ void test__kt_remove__directory_no_args__one_empty_not_exists_link(void **state)
     will_return(__wrap_fl_directory_do, 1);
     will_return(__wrap_fl_directory_do, &file);
     will_return(__wrap_fl_directory_do, &file);
-    will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_directory_e | f_directory_recurse_do_flag_top_after_e);
+    will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_directory_e);
+
+    // The pre-process gets called again before the final removal for directories.
+    will_return(__wrap_f_file_exists, F_true);
+    will_return(__wrap_f_file_is, F_true); // A link, kt_remove_flag_file_operate_link_d is set.
+    will_return(__wrap_f_file_stat, &statistics);
+    will_return(__wrap_f_file_stat, F_okay);
+    will_return(__wrap_f_directory_empty, F_true);
 
     // This will fail if f_directory_remove() is not called, therefore success here means f_directory_remove has been called.
     will_return(__wrap_f_directory_remove, F_okay);
@@ -287,7 +282,14 @@ void test__kt_remove__directory_no_args__one_empty_not_exists_link(void **state)
     will_return(__wrap_fl_directory_do, 1);
     will_return(__wrap_fl_directory_do, &file);
     will_return(__wrap_fl_directory_do, &file);
-    will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_directory_e | f_directory_recurse_do_flag_top_after_e);
+    will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_directory_e);
+
+    // The pre-process gets called again before the final removal for directories.
+    will_return(__wrap_f_file_exists, F_true);
+    will_return(__wrap_f_file_is, F_true); // A link, kt_remove_flag_file_operate_link_d is set.
+    will_return(__wrap_f_file_stat, &statistics);
+    will_return(__wrap_f_file_stat, F_okay);
+    will_return(__wrap_f_directory_empty, F_true);
 
     // This will fail if f_directory_remove() is not called, therefore success here means f_directory_remove has been called.
     will_return(__wrap_f_directory_remove, F_okay);
@@ -317,7 +319,14 @@ void test__kt_remove__directory_no_args__one_empty_not_exists_link(void **state)
     will_return(__wrap_fl_directory_do, 1);
     will_return(__wrap_fl_directory_do, &file);
     will_return(__wrap_fl_directory_do, &file);
-    will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_directory_e | f_directory_recurse_do_flag_top_after_e);
+    will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_directory_e);
+
+    // The pre-process gets called again before the final removal for directories.
+    will_return(__wrap_f_file_exists, F_true);
+    will_return(__wrap_f_file_is, F_true); // A link, kt_remove_flag_file_operate_link_d is set.
+    will_return(__wrap_f_file_stat, &statistics);
+    will_return(__wrap_f_file_stat, F_okay);
+    will_return(__wrap_f_directory_empty, F_true);
 
     // This will fail if f_directory_remove() is not called, therefore success here means f_directory_remove has been called.
     will_return(__wrap_f_directory_remove, F_okay);
@@ -334,6 +343,7 @@ void test__kt_remove__directory_no_args__one_empty_not_exists_link_not(void **st
   mock_unwrap_f_time_clock_get = 1;
 
   const f_string_static_t file = macro_f_string_static_t_initialize_1("to_remove", 0, 9);
+  const f_string_static_t child = macro_f_string_static_t_initialize_1("child", 0, 5);
 
   struct stat statistics;
   struct stat statistics_regular;
@@ -356,9 +366,16 @@ void test__kt_remove__directory_no_args__one_empty_not_exists_link_not(void **st
     // Directory processing.
     will_return(__wrap_f_directory_empty, F_false); // kt_remove_flag_file_operate_empty_d is set.
     will_return(__wrap_fl_directory_do, 1);
-    will_return(__wrap_fl_directory_do, &file);
-    will_return(__wrap_fl_directory_do, &file);
-    will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_directory_e | f_directory_recurse_do_flag_top_after_e);
+
+    // Child
+    will_return(__wrap_fl_directory_do, &child);
+    will_return(__wrap_fl_directory_do, &child);
+    will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_regular_e);
+    will_return(__wrap_f_file_exists, F_true);
+    will_return(__wrap_f_file_is, F_false); // Not a link, kt_remove_flag_file_operate_link_d is not set.
+    will_return(__wrap_f_file_stat, &statistics_regular);
+    will_return(__wrap_f_file_stat, F_okay);
+    will_return(__wrap_f_file_remove, F_okay);
 
     // This will fail if f_directory_remove() is not called, therefore success here means f_directory_remove has been called.
     will_return(__wrap_f_directory_remove, F_okay);
@@ -388,7 +405,14 @@ void test__kt_remove__directory_no_args__one_empty_not_exists_link_not(void **st
     will_return(__wrap_fl_directory_do, 1);
     will_return(__wrap_fl_directory_do, &file);
     will_return(__wrap_fl_directory_do, &file);
-    will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_directory_e | f_directory_recurse_do_flag_top_after_e);
+    will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_directory_e);
+
+    // The pre-process gets called again before the final removal for directories.
+    will_return(__wrap_f_file_exists, F_true);
+    will_return(__wrap_f_file_is, F_false); // Not a link, kt_remove_flag_file_operate_link_d is not set.
+    will_return(__wrap_f_file_stat, &statistics);
+    will_return(__wrap_f_file_stat, F_okay);
+    will_return(__wrap_f_directory_empty, F_true);
 
     // This will fail if f_directory_remove() is not called, therefore success here means f_directory_remove has been called.
     will_return(__wrap_f_directory_remove, F_okay);
@@ -418,7 +442,14 @@ void test__kt_remove__directory_no_args__one_empty_not_exists_link_not(void **st
     will_return(__wrap_fl_directory_do, 1);
     will_return(__wrap_fl_directory_do, &file);
     will_return(__wrap_fl_directory_do, &file);
-    will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_directory_e | f_directory_recurse_do_flag_top_after_e);
+    will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_directory_e);
+
+    // The pre-process gets called again before the final removal for directories.
+    will_return(__wrap_f_file_exists, F_true);
+    will_return(__wrap_f_file_is, F_false); // Not a link, kt_remove_flag_file_operate_link_d is not set.
+    will_return(__wrap_f_file_stat, &statistics);
+    will_return(__wrap_f_file_stat, F_okay);
+    will_return(__wrap_f_directory_empty, F_true);
 
     // This will fail if f_directory_remove() is not called, therefore success here means f_directory_remove has been called.
     will_return(__wrap_f_directory_remove, F_okay);
@@ -506,10 +537,8 @@ void test__kt_remove__directory_no_args__two_empty_exists_link(void **state) {
 
     // Directory processing.
     will_return(__wrap_f_directory_empty, F_true);
-    will_return(__wrap_fl_directory_do, 1);
-    will_return(__wrap_fl_directory_do, &file);
-    will_return(__wrap_fl_directory_do, &file);
-    will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_directory_e | f_directory_recurse_do_flag_top_after_e);
+    will_return(__wrap_fl_directory_do, 0);
+    will_return(__wrap_fl_directory_do, F_okay);
 
     // This will fail if f_directory_remove() is not called, therefore success here means f_directory_remove has been called.
     will_return(__wrap_f_directory_remove, F_okay);
@@ -522,10 +551,8 @@ void test__kt_remove__directory_no_args__two_empty_exists_link(void **state) {
 
     // Directory processing.
     will_return(__wrap_f_directory_empty, F_true);
-    will_return(__wrap_fl_directory_do, 1);
-    will_return(__wrap_fl_directory_do, &file);
-    will_return(__wrap_fl_directory_do, &file);
-    will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_directory_e | f_directory_recurse_do_flag_top_after_e);
+    will_return(__wrap_fl_directory_do, 0);
+    will_return(__wrap_fl_directory_do, F_okay);
 
     // This will fail if f_directory_remove() is not called, therefore success here means f_directory_remove has been called.
     will_return(__wrap_f_directory_remove, F_okay);
@@ -549,10 +576,8 @@ void test__kt_remove__directory_no_args__two_empty_exists_link(void **state) {
 
     // Directory processing.
     will_return(__wrap_f_directory_empty, F_true);
-    will_return(__wrap_fl_directory_do, 1);
-    will_return(__wrap_fl_directory_do, &file);
-    will_return(__wrap_fl_directory_do, &file);
-    will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_directory_e | f_directory_recurse_do_flag_top_after_e);
+    will_return(__wrap_fl_directory_do, 0);
+    will_return(__wrap_fl_directory_do, F_okay);
 
     // This will fail if f_directory_remove() is not called, therefore success here means f_directory_remove has been called.
     will_return(__wrap_f_directory_remove, F_okay);
@@ -565,10 +590,8 @@ void test__kt_remove__directory_no_args__two_empty_exists_link(void **state) {
 
     // Directory processing.
     will_return(__wrap_f_directory_empty, F_true);
-    will_return(__wrap_fl_directory_do, 1);
-    will_return(__wrap_fl_directory_do, &file);
-    will_return(__wrap_fl_directory_do, &file);
-    will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_directory_e | f_directory_recurse_do_flag_top_after_e);
+    will_return(__wrap_fl_directory_do, 0);
+    will_return(__wrap_fl_directory_do, F_okay);
 
     // This will fail if f_directory_remove() is not called, therefore success here means f_directory_remove has been called.
     will_return(__wrap_f_directory_remove, F_okay);
@@ -592,10 +615,8 @@ void test__kt_remove__directory_no_args__two_empty_exists_link(void **state) {
 
     // Directory processing.
     will_return(__wrap_f_directory_empty, F_true);
-    will_return(__wrap_fl_directory_do, 1);
-    will_return(__wrap_fl_directory_do, &file);
-    will_return(__wrap_fl_directory_do, &file);
-    will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_directory_e | f_directory_recurse_do_flag_top_after_e);
+    will_return(__wrap_fl_directory_do, 0);
+    will_return(__wrap_fl_directory_do, F_okay);
 
     // This will fail if f_directory_remove() is not called, therefore success here means f_directory_remove has been called.
     will_return(__wrap_f_directory_remove, F_okay);
@@ -608,10 +629,8 @@ void test__kt_remove__directory_no_args__two_empty_exists_link(void **state) {
 
     // Directory processing.
     will_return(__wrap_f_directory_empty, F_true);
-    will_return(__wrap_fl_directory_do, 1);
-    will_return(__wrap_fl_directory_do, &file);
-    will_return(__wrap_fl_directory_do, &file);
-    will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_directory_e | f_directory_recurse_do_flag_top_after_e);
+    will_return(__wrap_fl_directory_do, 0);
+    will_return(__wrap_fl_directory_do, F_okay);
 
     // This will fail if f_directory_remove() is not called, therefore success here means f_directory_remove has been called.
     will_return(__wrap_f_directory_remove, F_okay);
@@ -646,10 +665,8 @@ void test__kt_remove__directory_no_args__two_empty_exists_link_not(void **state)
 
     // Directory processing.
     will_return(__wrap_f_directory_empty, F_true);
-    will_return(__wrap_fl_directory_do, 1);
-    will_return(__wrap_fl_directory_do, &file);
-    will_return(__wrap_fl_directory_do, &file);
-    will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_directory_e | f_directory_recurse_do_flag_top_after_e);
+    will_return(__wrap_fl_directory_do, 0);
+    will_return(__wrap_fl_directory_do, F_okay);
 
     // This will fail if f_directory_remove() is not called, therefore success here means f_directory_remove has been called.
     will_return(__wrap_f_directory_remove, F_okay);
@@ -662,10 +679,8 @@ void test__kt_remove__directory_no_args__two_empty_exists_link_not(void **state)
 
     // Directory processing.
     will_return(__wrap_f_directory_empty, F_true);
-    will_return(__wrap_fl_directory_do, 1);
-    will_return(__wrap_fl_directory_do, &file);
-    will_return(__wrap_fl_directory_do, &file);
-    will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_directory_e | f_directory_recurse_do_flag_top_after_e);
+    will_return(__wrap_fl_directory_do, 0);
+    will_return(__wrap_fl_directory_do, F_okay);
 
     // This will fail if f_directory_remove() is not called, therefore success here means f_directory_remove has been called.
     will_return(__wrap_f_directory_remove, F_okay);
@@ -689,10 +704,8 @@ void test__kt_remove__directory_no_args__two_empty_exists_link_not(void **state)
 
     // Directory processing.
     will_return(__wrap_f_directory_empty, F_true);
-    will_return(__wrap_fl_directory_do, 1);
-    will_return(__wrap_fl_directory_do, &file);
-    will_return(__wrap_fl_directory_do, &file);
-    will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_directory_e | f_directory_recurse_do_flag_top_after_e);
+    will_return(__wrap_fl_directory_do, 0);
+    will_return(__wrap_fl_directory_do, F_okay);
 
     // This will fail if f_directory_remove() is not called, therefore success here means f_directory_remove has been called.
     will_return(__wrap_f_directory_remove, F_okay);
@@ -705,10 +718,8 @@ void test__kt_remove__directory_no_args__two_empty_exists_link_not(void **state)
 
     // Directory processing.
     will_return(__wrap_f_directory_empty, F_true);
-    will_return(__wrap_fl_directory_do, 1);
-    will_return(__wrap_fl_directory_do, &file);
-    will_return(__wrap_fl_directory_do, &file);
-    will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_directory_e | f_directory_recurse_do_flag_top_after_e);
+    will_return(__wrap_fl_directory_do, 0);
+    will_return(__wrap_fl_directory_do, F_okay);
 
     // This will fail if f_directory_remove() is not called, therefore success here means f_directory_remove has been called.
     will_return(__wrap_f_directory_remove, F_okay);
@@ -732,10 +743,8 @@ void test__kt_remove__directory_no_args__two_empty_exists_link_not(void **state)
 
     // Directory processing.
     will_return(__wrap_f_directory_empty, F_true);
-    will_return(__wrap_fl_directory_do, 1);
-    will_return(__wrap_fl_directory_do, &file);
-    will_return(__wrap_fl_directory_do, &file);
-    will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_directory_e | f_directory_recurse_do_flag_top_after_e);
+    will_return(__wrap_fl_directory_do, 0);
+    will_return(__wrap_fl_directory_do, F_okay);
 
     // This will fail if f_directory_remove() is not called, therefore success here means f_directory_remove has been called.
     will_return(__wrap_f_directory_remove, F_okay);
@@ -748,10 +757,8 @@ void test__kt_remove__directory_no_args__two_empty_exists_link_not(void **state)
 
     // Directory processing.
     will_return(__wrap_f_directory_empty, F_true);
-    will_return(__wrap_fl_directory_do, 1);
-    will_return(__wrap_fl_directory_do, &file);
-    will_return(__wrap_fl_directory_do, &file);
-    will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_directory_e | f_directory_recurse_do_flag_top_after_e);
+    will_return(__wrap_fl_directory_do, 0);
+    will_return(__wrap_fl_directory_do, F_okay);
 
     // This will fail if f_directory_remove() is not called, therefore success here means f_directory_remove has been called.
     will_return(__wrap_f_directory_remove, F_okay);
index 04bbef439179a038372d06489b883fadc9b2e9f0..163e9fccec5f45a6b18477a125604716372731b4 100644 (file)
@@ -45,20 +45,8 @@ void test__kt_remove__directory_recurse_simple__one_child_one_exists_link(void *
     will_return(__wrap_f_file_is, F_false); // Not a link, kt_remove_flag_file_operate_link_d is not set.
     will_return(__wrap_f_file_stat, &stat_regular);
     will_return(__wrap_f_file_stat, F_okay);
-
-    // Target Directory processing, begin.
-    will_return(__wrap_fl_directory_do, 2);
-
-    // The first child processing.
-    will_return(__wrap_fl_directory_do, &child_1);
-    will_return(__wrap_fl_directory_do, &child_1);
-    will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_regular_e);
     will_return(__wrap_f_file_remove, F_okay);
 
-    // Target Directory processing, continue.
-    will_return(__wrap_fl_directory_do, &target);
-    will_return(__wrap_fl_directory_do, &target);
-    will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_directory_e | f_directory_recurse_do_flag_top_after_e);
     will_return(__wrap_f_directory_remove, F_okay);
 
     const int result = kt_main_test__remove(3, argv, 0);
@@ -105,20 +93,8 @@ void test__kt_remove__directory_recurse_simple__one_child_one_exists_link_not(vo
     will_return(__wrap_f_file_is, F_false); // Not a link, kt_remove_flag_file_operate_link_d is not set.
     will_return(__wrap_f_file_stat, &stat_regular);
     will_return(__wrap_f_file_stat, F_okay);
-
-    // Target Directory processing, begin.
-    will_return(__wrap_fl_directory_do, 2);
-
-    // The first child processing.
-    will_return(__wrap_fl_directory_do, &child_1);
-    will_return(__wrap_fl_directory_do, &child_1);
-    will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_regular_e);
     will_return(__wrap_f_file_remove, F_okay);
 
-    // Target Directory processing, continue.
-    will_return(__wrap_fl_directory_do, &target);
-    will_return(__wrap_fl_directory_do, &target);
-    will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_directory_e | f_directory_recurse_do_flag_top_after_e);
     will_return(__wrap_f_directory_remove, F_okay);
 
     const int result = kt_main_test__remove(3, argv, 0);
@@ -158,7 +134,7 @@ void test__kt_remove__directory_recurse_simple__one_child_two_exists_link(void *
     will_return(__wrap_f_directory_empty, F_false);
     will_return(__wrap_fl_directory_do, 2);
 
-    // The first child pre-processing.
+    // The first child processing.
     will_return(__wrap_fl_directory_do, &child_1);
     will_return(__wrap_fl_directory_do, &child_1);
     will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_regular_e);
@@ -166,8 +142,9 @@ void test__kt_remove__directory_recurse_simple__one_child_two_exists_link(void *
     will_return(__wrap_f_file_is, F_false); // Not a link, kt_remove_flag_file_operate_link_d is not set.
     will_return(__wrap_f_file_stat, &stat_regular);
     will_return(__wrap_f_file_stat, F_okay);
+    will_return(__wrap_f_file_remove, F_okay);
 
-    // The second child pre-processing.
+    // The second child processing.
     will_return(__wrap_fl_directory_do, &child_2);
     will_return(__wrap_fl_directory_do, &child_2);
     will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_regular_e);
@@ -175,26 +152,8 @@ void test__kt_remove__directory_recurse_simple__one_child_two_exists_link(void *
     will_return(__wrap_f_file_is, F_true); // A link, kt_remove_flag_file_operate_link_d is set.
     will_return(__wrap_f_file_stat, &stat_regular);
     will_return(__wrap_f_file_stat, F_okay);
-
-    // Target Directory processing, begin.
-    will_return(__wrap_fl_directory_do, 3);
-
-    // The first child processing.
-    will_return(__wrap_fl_directory_do, &child_1);
-    will_return(__wrap_fl_directory_do, &child_1);
-    will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_regular_e);
-    will_return(__wrap_f_file_remove, F_okay);
-
-    // The second child processing.
-    will_return(__wrap_fl_directory_do, &child_2);
-    will_return(__wrap_fl_directory_do, &child_2);
-    will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_regular_e);
     will_return(__wrap_f_file_remove, F_okay);
 
-    // Target Directory processing, continue.
-    will_return(__wrap_fl_directory_do, &target);
-    will_return(__wrap_fl_directory_do, &target);
-    will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_directory_e | f_directory_recurse_do_flag_top_after_e);
     will_return(__wrap_f_directory_remove, F_okay);
 
     const int result = kt_main_test__remove(3, argv, 0);
@@ -234,7 +193,7 @@ void test__kt_remove__directory_recurse_simple__one_child_two_exists_link_not(vo
     will_return(__wrap_f_directory_empty, F_false);
     will_return(__wrap_fl_directory_do, 2);
 
-    // The first child pre-processing.
+    // The first child processing.
     will_return(__wrap_fl_directory_do, &child_1);
     will_return(__wrap_fl_directory_do, &child_1);
     will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_regular_e);
@@ -242,8 +201,9 @@ void test__kt_remove__directory_recurse_simple__one_child_two_exists_link_not(vo
     will_return(__wrap_f_file_is, F_false); // Not a link, kt_remove_flag_file_operate_link_d is not set.
     will_return(__wrap_f_file_stat, &stat_regular);
     will_return(__wrap_f_file_stat, F_okay);
+    will_return(__wrap_f_file_remove, F_okay);
 
-    // The second child pre-processing.
+    // The second child processing.
     will_return(__wrap_fl_directory_do, &child_2);
     will_return(__wrap_fl_directory_do, &child_2);
     will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_regular_e);
@@ -251,26 +211,8 @@ void test__kt_remove__directory_recurse_simple__one_child_two_exists_link_not(vo
     will_return(__wrap_f_file_is, F_true); // A link, kt_remove_flag_file_operate_link_d is set.
     will_return(__wrap_f_file_stat, &stat_regular);
     will_return(__wrap_f_file_stat, F_okay);
-
-    // Target Directory processing, begin.
-    will_return(__wrap_fl_directory_do, 3);
-
-    // The first child processing.
-    will_return(__wrap_fl_directory_do, &child_1);
-    will_return(__wrap_fl_directory_do, &child_1);
-    will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_regular_e);
-    will_return(__wrap_f_file_remove, F_okay);
-
-    // The second child processing.
-    will_return(__wrap_fl_directory_do, &child_2);
-    will_return(__wrap_fl_directory_do, &child_2);
-    will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_regular_e);
     will_return(__wrap_f_file_remove, F_okay);
 
-    // Target Directory processing, continue.
-    will_return(__wrap_fl_directory_do, &target);
-    will_return(__wrap_fl_directory_do, &target);
-    will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_directory_e | f_directory_recurse_do_flag_top_after_e);
     will_return(__wrap_f_directory_remove, F_okay);
 
     const int result = kt_main_test__remove(3, argv, 0);
index 129a48e06d4c32901778529640fc68353b619d34..bfacdf67b1c08ce592ab2adb635d71dee5a91247 100644 (file)
@@ -144,10 +144,9 @@ void test__kt_remove__epochtime__accessed_works(void **state) {
 
           if (time_spec_removes[date]) {
             if (macro_f_file_type_is_directory(stats[type].st_mode)) {
-              will_return(__wrap_fl_directory_do, 1);
-              will_return(__wrap_fl_directory_do, &target);
-              will_return(__wrap_fl_directory_do, &target);
-              will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_directory_e | f_directory_recurse_do_flag_top_after_e);
+              will_return(__wrap_fl_directory_do, 0);
+              will_return(__wrap_fl_directory_do, F_okay);
+
               will_return(__wrap_f_directory_remove, F_okay);
             }
             else {
@@ -301,10 +300,9 @@ void test__kt_remove__epochtime__changed_works(void **state) {
 
           if (time_spec_removes[date]) {
             if (macro_f_file_type_is_directory(stats[type].st_mode)) {
-              will_return(__wrap_fl_directory_do, 1);
-              will_return(__wrap_fl_directory_do, &target);
-              will_return(__wrap_fl_directory_do, &target);
-              will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_directory_e | f_directory_recurse_do_flag_top_after_e);
+              will_return(__wrap_fl_directory_do, 0);
+              will_return(__wrap_fl_directory_do, F_okay);
+
               will_return(__wrap_f_directory_remove, F_okay);
             }
             else {
@@ -458,10 +456,9 @@ void test__kt_remove__epochtime__updated_works(void **state) {
 
           if (time_spec_removes[date]) {
             if (macro_f_file_type_is_directory(stats[type].st_mode)) {
-              will_return(__wrap_fl_directory_do, 1);
-              will_return(__wrap_fl_directory_do, &target);
-              will_return(__wrap_fl_directory_do, &target);
-              will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_directory_e | f_directory_recurse_do_flag_top_after_e);
+              will_return(__wrap_fl_directory_do, 0);
+              will_return(__wrap_fl_directory_do, F_okay);
+
               will_return(__wrap_f_directory_remove, F_okay);
             }
             else {
index b37c549023c0c32335978311a1dbc8f21a6b8e6d..c54dac21f3985a7fc243a1e58bfaa56d997c3ed7 100644 (file)
@@ -69,29 +69,28 @@ void test__kt_remove__file_mode__different_works(void **state) {
 
           const f_string_t argv[] = { "mocked_main", target.string, "-" KT_REMOVE_short_mode_s, kt_remove_mode_word_different_s.string, params[param], 0 };
 
-          struct stat stat_file;
+          struct stat statistics;
 
-          memset(&stat_file, 0, sizeof(struct stat));
+          memset(&statistics, 0, sizeof(struct stat));
 
           // The unknown type at the last index requires '&' logic rather than '|' logic.
-          stat_file.st_mode = types[type] == ~S_IFMT
+          statistics.st_mode = types[type] == ~S_IFMT
             ? modes[mode] & types[type]
             : modes[mode] | types[type];
 
           // Pre-process file.
           will_return(__wrap_f_file_exists, F_true);
-          will_return(__wrap_f_file_is, macro_f_file_type_is_link(stat_file.st_mode));
-          will_return(__wrap_f_file_stat, &stat_file);
+          will_return(__wrap_f_file_is, macro_f_file_type_is_link(statistics.st_mode));
+          will_return(__wrap_f_file_stat, &statistics);
           will_return(__wrap_f_file_stat, F_okay);
 
           // Process file.
           if (param != mode) {
-            if (macro_f_file_type_is_directory(stat_file.st_mode)) {
+            if (macro_f_file_type_is_directory(statistics.st_mode)) {
               will_return(__wrap_f_directory_empty, F_true);
-              will_return(__wrap_fl_directory_do, 1);
-              will_return(__wrap_fl_directory_do, &target);
-              will_return(__wrap_fl_directory_do, &target);
-              will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_directory_e | f_directory_recurse_do_flag_top_after_e);
+              will_return(__wrap_fl_directory_do, 0);
+              will_return(__wrap_fl_directory_do, F_okay);
+
               will_return(__wrap_f_directory_remove, F_okay);
             }
             else {
@@ -99,7 +98,7 @@ void test__kt_remove__file_mode__different_works(void **state) {
             }
           }
           else {
-            if (macro_f_file_type_is_directory(stat_file.st_mode)) {
+            if (macro_f_file_type_is_directory(statistics.st_mode)) {
               will_return(__wrap_f_directory_empty, F_true);
             }
           }
@@ -175,29 +174,28 @@ void test__kt_remove__file_mode__same_works(void **state) {
 
           const f_string_t argv[] = { "mocked_main", target.string, "-" KT_REMOVE_short_mode_s, kt_remove_mode_word_same_s.string, params[param], 0 };
 
-          struct stat stat_file;
+          struct stat statistics;
 
-          memset(&stat_file, 0, sizeof(struct stat));
+          memset(&statistics, 0, sizeof(struct stat));
 
           // The unknown type at the last index requires '&' logic rather than '|' logic.
-          stat_file.st_mode = types[type] == ~S_IFMT
+          statistics.st_mode = types[type] == ~S_IFMT
             ? modes[mode] & types[type]
             : modes[mode] | types[type];
 
           // Pre-process file.
           will_return(__wrap_f_file_exists, F_true);
-          will_return(__wrap_f_file_is, macro_f_file_type_is_link(stat_file.st_mode));
-          will_return(__wrap_f_file_stat, &stat_file);
+          will_return(__wrap_f_file_is, macro_f_file_type_is_link(statistics.st_mode));
+          will_return(__wrap_f_file_stat, &statistics);
           will_return(__wrap_f_file_stat, F_okay);
 
           // Process file.
           if (param == mode) {
-            if (macro_f_file_type_is_directory(stat_file.st_mode)) {
+            if (macro_f_file_type_is_directory(statistics.st_mode)) {
               will_return(__wrap_f_directory_empty, F_true);
-              will_return(__wrap_fl_directory_do, 1);
-              will_return(__wrap_fl_directory_do, &target);
-              will_return(__wrap_fl_directory_do, &target);
-              will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_directory_e | f_directory_recurse_do_flag_top_after_e);
+              will_return(__wrap_fl_directory_do, 0);
+              will_return(__wrap_fl_directory_do, F_okay);
+
               will_return(__wrap_f_directory_remove, F_okay);
             }
             else {
@@ -205,7 +203,7 @@ void test__kt_remove__file_mode__same_works(void **state) {
             }
           }
           else {
-            if (macro_f_file_type_is_directory(stat_file.st_mode)) {
+            if (macro_f_file_type_is_directory(statistics.st_mode)) {
               will_return(__wrap_f_directory_empty, F_true);
             }
           }
@@ -281,29 +279,28 @@ void test__kt_remove__file_mode__similar_works(void **state) {
 
           const f_string_t argv[] = { "mocked_main", target.string, "-" KT_REMOVE_short_mode_s, kt_remove_mode_word_similar_s.string, params[param], 0 };
 
-          struct stat stat_file;
+          struct stat statistics;
 
-          memset(&stat_file, 0, sizeof(struct stat));
+          memset(&statistics, 0, sizeof(struct stat));
 
           // The unknown type at the last index requires '&' logic rather than '|' logic.
-          stat_file.st_mode = types[type] == ~S_IFMT
+          statistics.st_mode = types[type] == ~S_IFMT
             ? modes[mode] & types[type]
             : modes[mode] | types[type];
 
           // Pre-process file.
           will_return(__wrap_f_file_exists, F_true);
-          will_return(__wrap_f_file_is, macro_f_file_type_is_link(stat_file.st_mode));
-          will_return(__wrap_f_file_stat, &stat_file);
+          will_return(__wrap_f_file_is, macro_f_file_type_is_link(statistics.st_mode));
+          will_return(__wrap_f_file_stat, &statistics);
           will_return(__wrap_f_file_stat, F_okay);
 
           // Process file.
           if (modes[param] & modes[mode]) {
-            if (macro_f_file_type_is_directory(stat_file.st_mode)) {
+            if (macro_f_file_type_is_directory(statistics.st_mode)) {
               will_return(__wrap_f_directory_empty, F_true);
-              will_return(__wrap_fl_directory_do, 1);
-              will_return(__wrap_fl_directory_do, &target);
-              will_return(__wrap_fl_directory_do, &target);
-              will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_directory_e | f_directory_recurse_do_flag_top_after_e);
+              will_return(__wrap_fl_directory_do, 0);
+              will_return(__wrap_fl_directory_do, F_okay);
+
               will_return(__wrap_f_directory_remove, F_okay);
             }
             else {
@@ -311,7 +308,7 @@ void test__kt_remove__file_mode__similar_works(void **state) {
             }
           }
           else {
-            if (macro_f_file_type_is_directory(stat_file.st_mode)) {
+            if (macro_f_file_type_is_directory(statistics.st_mode)) {
               will_return(__wrap_f_directory_empty, F_true);
             }
           }
@@ -387,29 +384,28 @@ void test__kt_remove__file_mode__not_works(void **state) {
 
           const f_string_t argv[] = { "mocked_main", target.string, "-" KT_REMOVE_short_mode_s, kt_remove_mode_word_not_s.string, params[param], 0 };
 
-          struct stat stat_file;
+          struct stat statistics;
 
-          memset(&stat_file, 0, sizeof(struct stat));
+          memset(&statistics, 0, sizeof(struct stat));
 
           // The unknown type at the last index requires '&' logic rather than '|' logic.
-          stat_file.st_mode = types[type] == ~S_IFMT
+          statistics.st_mode = types[type] == ~S_IFMT
             ? modes[mode] & types[type]
             : modes[mode] | types[type];
 
           // Pre-process file.
           will_return(__wrap_f_file_exists, F_true);
-          will_return(__wrap_f_file_is, macro_f_file_type_is_link(stat_file.st_mode));
-          will_return(__wrap_f_file_stat, &stat_file);
+          will_return(__wrap_f_file_is, macro_f_file_type_is_link(statistics.st_mode));
+          will_return(__wrap_f_file_stat, &statistics);
           will_return(__wrap_f_file_stat, F_okay);
 
           // Process file.
           if (modes[param] != modes[mode]) {
-            if (macro_f_file_type_is_directory(stat_file.st_mode)) {
+            if (macro_f_file_type_is_directory(statistics.st_mode)) {
               will_return(__wrap_f_directory_empty, F_true);
-              will_return(__wrap_fl_directory_do, 1);
-              will_return(__wrap_fl_directory_do, &target);
-              will_return(__wrap_fl_directory_do, &target);
-              will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_directory_e | f_directory_recurse_do_flag_top_after_e);
+              will_return(__wrap_fl_directory_do, 0);
+              will_return(__wrap_fl_directory_do, F_okay);
+
               will_return(__wrap_f_directory_remove, F_okay);
             }
             else {
@@ -417,7 +413,7 @@ void test__kt_remove__file_mode__not_works(void **state) {
             }
           }
           else {
-            if (macro_f_file_type_is_directory(stat_file.st_mode)) {
+            if (macro_f_file_type_is_directory(statistics.st_mode)) {
               will_return(__wrap_f_directory_empty, F_true);
             }
           }
index 90a9646266f51f55e56b43abd91ad81ae1b3e390..622da78507234e9d9431044c9971f5eaaa525407 100644 (file)
@@ -60,10 +60,9 @@ void test__kt_remove__file_type__works(void **state) {
         if (i == type) {
           if (macro_f_file_type_is_directory(stats[i].st_mode)) {
             will_return(__wrap_f_directory_empty, F_true);
-            will_return(__wrap_fl_directory_do, 1);
-            will_return(__wrap_fl_directory_do, &target);
-            will_return(__wrap_fl_directory_do, &target);
-            will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_directory_e | f_directory_recurse_do_flag_top_after_e);
+              will_return(__wrap_fl_directory_do, 0);
+              will_return(__wrap_fl_directory_do, F_okay);
+
             will_return(__wrap_f_directory_remove, F_okay);
           }
           else {
index f452aac24a85e9d272e2973c9990cc68262f6783..6ee6e6e2a8a7e39440706263d6724c9147fe4749 100644 (file)
@@ -32,7 +32,7 @@ void test__kt_remove__group__name_works(void **state) {
   stats[2].st_gid = 1;
   stats[3].st_gid = 2;
 
-  for (uint8_t i = 0; i < total; ++i) {
+  for (uint8_t type = 0; type < total; ++type) {
 
     will_return(__wrap_f_account_group_id_by_name, group_id);
     will_return(__wrap_f_account_group_id_by_name, F_okay);
@@ -40,17 +40,16 @@ void test__kt_remove__group__name_works(void **state) {
     // Pre-process file.
     will_return(__wrap_f_file_exists, F_true);
     will_return(__wrap_f_file_is, F_false); // Not a link, kt_remove_flag_file_operate_link_d is not set.
-    will_return(__wrap_f_file_stat, &stats[i]);
+    will_return(__wrap_f_file_stat, &stats[type]);
     will_return(__wrap_f_file_stat, F_okay);
 
     // Process file.
-    if (stats[i].st_gid == group_id) {
-      if (macro_f_file_type_is_directory(stats[i].st_mode)) {
+    if (stats[type].st_gid == group_id) {
+      if (macro_f_file_type_is_directory(stats[type].st_mode)) {
         will_return(__wrap_f_directory_empty, F_true);
-        will_return(__wrap_fl_directory_do, 1);
-        will_return(__wrap_fl_directory_do, &target);
-        will_return(__wrap_fl_directory_do, &target);
-        will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_directory_e | f_directory_recurse_do_flag_top_after_e);
+              will_return(__wrap_fl_directory_do, 0);
+              will_return(__wrap_fl_directory_do, F_okay);
+
         will_return(__wrap_f_directory_remove, F_okay);
       }
       else {
@@ -58,7 +57,7 @@ void test__kt_remove__group__name_works(void **state) {
       }
     }
     else {
-      if (macro_f_file_type_is_directory(stats[i].st_mode)) {
+      if (macro_f_file_type_is_directory(stats[type].st_mode)) {
         will_return(__wrap_f_directory_empty, F_true);
       }
     }
index e1e606dd5c4adc432e548c5e0d22e93fc89fb333..b4d645fd8b1ad5182d2956bcfc022b1cd27bba7a 100644 (file)
@@ -151,10 +151,9 @@ void test__kt_remove__time__accessed_works(void **state) {
 
           if (time_spec_removes[date]) {
             if (macro_f_file_type_is_directory(stats[type].st_mode)) {
-              will_return(__wrap_fl_directory_do, 1);
-              will_return(__wrap_fl_directory_do, &target);
-              will_return(__wrap_fl_directory_do, &target);
-              will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_directory_e | f_directory_recurse_do_flag_top_after_e);
+              will_return(__wrap_fl_directory_do, 0);
+              will_return(__wrap_fl_directory_do, F_okay);
+
               will_return(__wrap_f_directory_remove, F_okay);
             }
             else {
@@ -315,10 +314,9 @@ void test__kt_remove__time__changed_works(void **state) {
 
           if (time_spec_removes[date]) {
             if (macro_f_file_type_is_directory(stats[type].st_mode)) {
-              will_return(__wrap_fl_directory_do, 1);
-              will_return(__wrap_fl_directory_do, &target);
-              will_return(__wrap_fl_directory_do, &target);
-              will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_directory_e | f_directory_recurse_do_flag_top_after_e);
+              will_return(__wrap_fl_directory_do, 0);
+              will_return(__wrap_fl_directory_do, F_okay);
+
               will_return(__wrap_f_directory_remove, F_okay);
             }
             else {
@@ -479,10 +477,9 @@ void test__kt_remove__time__updated_works(void **state) {
 
           if (time_spec_removes[date]) {
             if (macro_f_file_type_is_directory(stats[type].st_mode)) {
-              will_return(__wrap_fl_directory_do, 1);
-              will_return(__wrap_fl_directory_do, &target);
-              will_return(__wrap_fl_directory_do, &target);
-              will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_directory_e | f_directory_recurse_do_flag_top_after_e);
+              will_return(__wrap_fl_directory_do, 0);
+              will_return(__wrap_fl_directory_do, F_okay);
+
               will_return(__wrap_f_directory_remove, F_okay);
             }
             else {
index dd925cc413f9843145c5c98eed0e7b16d32acebe..2a8a4c79005a61dd29edce2241c8d918d03d1a0d 100644 (file)
@@ -138,10 +138,9 @@ void test__kt_remove__unix__accessed_works(void **state) {
 
         if (time_spec_removes[date]) {
           if (macro_f_file_type_is_directory(stats[type].st_mode)) {
-            will_return(__wrap_fl_directory_do, 1);
-            will_return(__wrap_fl_directory_do, &target);
-            will_return(__wrap_fl_directory_do, &target);
-            will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_directory_e | f_directory_recurse_do_flag_top_after_e);
+            will_return(__wrap_fl_directory_do, 0);
+            will_return(__wrap_fl_directory_do, F_okay);
+
             will_return(__wrap_f_directory_remove, F_okay);
           }
           else {
@@ -287,10 +286,9 @@ void test__kt_remove__unix__changed_works(void **state) {
 
         if (time_spec_removes[date]) {
           if (macro_f_file_type_is_directory(stats[type].st_mode)) {
-            will_return(__wrap_fl_directory_do, 1);
-            will_return(__wrap_fl_directory_do, &target);
-            will_return(__wrap_fl_directory_do, &target);
-            will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_directory_e | f_directory_recurse_do_flag_top_after_e);
+            will_return(__wrap_fl_directory_do, 0);
+            will_return(__wrap_fl_directory_do, F_okay);
+
             will_return(__wrap_f_directory_remove, F_okay);
           }
           else {
@@ -436,10 +434,9 @@ void test__kt_remove__unix__updated_works(void **state) {
 
         if (time_spec_removes[date]) {
           if (macro_f_file_type_is_directory(stats[type].st_mode)) {
-            will_return(__wrap_fl_directory_do, 1);
-            will_return(__wrap_fl_directory_do, &target);
-            will_return(__wrap_fl_directory_do, &target);
-            will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_directory_e | f_directory_recurse_do_flag_top_after_e);
+            will_return(__wrap_fl_directory_do, 0);
+            will_return(__wrap_fl_directory_do, F_okay);
+
             will_return(__wrap_f_directory_remove, F_okay);
           }
           else {
index 96ce65bf74acdd60eb905b7cefc7a0aac11070db..decf56888bf8c52a1bd82211c6badc834b6878ba 100644 (file)
@@ -32,7 +32,7 @@ void test__kt_remove__user__different_works(void **state) {
   stats[2].st_uid = 1;
   stats[3].st_uid = 2;
 
-  for (uint8_t i = 0; i < total; ++i) {
+  for (uint8_t type = 0; type < total; ++type) {
 
     will_return(__wrap_geteuid, user_id);
     will_return(__wrap_geteuid, user_id);
@@ -40,22 +40,21 @@ void test__kt_remove__user__different_works(void **state) {
     // Pre-process file.
     will_return(__wrap_f_file_exists, F_true);
     will_return(__wrap_f_file_is, F_false); // Not a link, kt_remove_flag_file_operate_link_d is not set.
-    will_return(__wrap_f_file_stat, &stats[i]);
+    will_return(__wrap_f_file_stat, &stats[type]);
     will_return(__wrap_f_file_stat, F_okay);
 
     // Process file.
-    if (stats[i].st_uid == user_id) {
-      if (macro_f_file_type_is_directory(stats[i].st_mode)) {
+    if (stats[type].st_uid == user_id) {
+      if (macro_f_file_type_is_directory(stats[type].st_mode)) {
         will_return(__wrap_f_directory_empty, F_true);
       }
     }
     else {
-      if (macro_f_file_type_is_directory(stats[i].st_mode)) {
+      if (macro_f_file_type_is_directory(stats[type].st_mode)) {
         will_return(__wrap_f_directory_empty, F_true);
-        will_return(__wrap_fl_directory_do, 1);
-        will_return(__wrap_fl_directory_do, &target);
-        will_return(__wrap_fl_directory_do, &target);
-        will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_directory_e | f_directory_recurse_do_flag_top_after_e);
+        will_return(__wrap_fl_directory_do, 0);
+        will_return(__wrap_fl_directory_do, F_okay);
+
         will_return(__wrap_f_directory_remove, F_okay);
       }
       else {
@@ -94,7 +93,7 @@ void test__kt_remove__user__name_works(void **state) {
   stats[2].st_uid = 1;
   stats[3].st_uid = 2;
 
-  for (uint8_t i = 0; i < total; ++i) {
+  for (uint8_t type = 0; type < total; ++type) {
 
     will_return(__wrap_f_account_id_by_name, user_id);
     will_return(__wrap_f_account_id_by_name, F_okay);
@@ -102,17 +101,16 @@ void test__kt_remove__user__name_works(void **state) {
     // Pre-process file.
     will_return(__wrap_f_file_exists, F_true);
     will_return(__wrap_f_file_is, F_false); // Not a link, kt_remove_flag_file_operate_link_d is not set.
-    will_return(__wrap_f_file_stat, &stats[i]);
+    will_return(__wrap_f_file_stat, &stats[type]);
     will_return(__wrap_f_file_stat, F_okay);
 
     // Process file.
-    if (stats[i].st_uid == user_id) {
-      if (macro_f_file_type_is_directory(stats[i].st_mode)) {
+    if (stats[type].st_uid == user_id) {
+      if (macro_f_file_type_is_directory(stats[type].st_mode)) {
         will_return(__wrap_f_directory_empty, F_true);
-        will_return(__wrap_fl_directory_do, 1);
-        will_return(__wrap_fl_directory_do, &target);
-        will_return(__wrap_fl_directory_do, &target);
-        will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_directory_e | f_directory_recurse_do_flag_top_after_e);
+        will_return(__wrap_fl_directory_do, 0);
+        will_return(__wrap_fl_directory_do, F_okay);
+
         will_return(__wrap_f_directory_remove, F_okay);
       }
       else {
@@ -120,7 +118,7 @@ void test__kt_remove__user__name_works(void **state) {
       }
     }
     else {
-      if (macro_f_file_type_is_directory(stats[i].st_mode)) {
+      if (macro_f_file_type_is_directory(stats[type].st_mode)) {
         will_return(__wrap_f_directory_empty, F_true);
       }
     }
@@ -156,7 +154,7 @@ void test__kt_remove__user__same_works(void **state) {
   stats[2].st_uid = 1;
   stats[3].st_uid = 2;
 
-  for (uint8_t i = 0; i < total; ++i) {
+  for (uint8_t type = 0; type < total; ++type) {
 
     will_return(__wrap_geteuid, user_id);
     will_return(__wrap_geteuid, user_id);
@@ -164,17 +162,16 @@ void test__kt_remove__user__same_works(void **state) {
     // Pre-process file.
     will_return(__wrap_f_file_exists, F_true);
     will_return(__wrap_f_file_is, F_false); // Not a link, kt_remove_flag_file_operate_link_d is not set.
-    will_return(__wrap_f_file_stat, &stats[i]);
+    will_return(__wrap_f_file_stat, &stats[type]);
     will_return(__wrap_f_file_stat, F_okay);
 
     // Process file.
-    if (stats[i].st_uid == user_id) {
-      if (macro_f_file_type_is_directory(stats[i].st_mode)) {
+    if (stats[type].st_uid == user_id) {
+      if (macro_f_file_type_is_directory(stats[type].st_mode)) {
         will_return(__wrap_f_directory_empty, F_true);
-        will_return(__wrap_fl_directory_do, 1);
-        will_return(__wrap_fl_directory_do, &target);
-        will_return(__wrap_fl_directory_do, &target);
-        will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_e | f_directory_recurse_do_flag_directory_e | f_directory_recurse_do_flag_top_after_e);
+        will_return(__wrap_fl_directory_do, 0);
+        will_return(__wrap_fl_directory_do, F_okay);
+
         will_return(__wrap_f_directory_remove, F_okay);
       }
       else {
@@ -182,7 +179,7 @@ void test__kt_remove__user__same_works(void **state) {
       }
     }
     else {
-      if (macro_f_file_type_is_directory(stats[i].st_mode)) {
+      if (macro_f_file_type_is_directory(stats[type].st_mode)) {
         will_return(__wrap_f_directory_empty, F_true);
       }
     }