]> Kevux Git Server - kevux-tools/commitdiff
Bugfix: Handle deleting on access denied errors.
authorKevin Day <Kevin@kevux.org>
Sun, 15 Jun 2025 16:02:14 +0000 (11:02 -0500)
committerKevin Day <Kevin@kevux.org>
Sun, 15 Jun 2025 23:25:01 +0000 (18:25 -0500)
Detect the read, write, and execute permissions.
Print the unable to read, write, and execute status for each path when in simulate mode.

Add additional strings as needed.
Address an alphabet ordering mistake in the strings.

The preprocess now happens outside of the process function.
This better allows for calling the preprocess in the "before" state of the recursion and the process happens during the "action" state of the recursion.
This also allows for completely avoiding a second preprocess call for depth 0 recursive paths.

The operate flag is now handled on a per depth basis.
This requires a new array of flags for each depth.

The `normal` part of `kt_remove_flag_recurse_*_d` now use the work `active` instead of `normal`.
This makes reading and understanding the code easier given the more direct meaning of the word.

With the preprocess logic now outside of the process logic, the `top` and `parent` recurse states from `kt_remove_flag_recurse_*_d` no longer need to be part of the preprocess.
They are not used anywhere else so remove them.

Make the code simpler by just using an `uint64_t` rather than an `uint32_t` for the operate flag.
This also avoids the need for casting when adding it to the recurse code value.

Update the `remove-config.h`.
I noticed that the sorting is working differently from system to system.
I had to manually adjust/correct some of the ordering and I may have missed some things.
I will need to figure out the cause of the inconsistency at some point.

Fix the linking to make sure the fl_path library is included.
Also make sure the static library link paths are used in the tests as well.

A new flag `return_fail` main flag is added to designate that the final state should be a failure.
This is done because a single file remove failure on file does not exist should not prevent other failures.
(The classic `rm` command will remove all files that it can and return an error for any error.)

The unit tests are updated.
The unit tests are updated to respect the 32-bit to 64-bit type change.
The unit tests now handles the `f_file_access()` calls.
The unit tests now handles the updated directory recursion and pre-process flow.
The `recurse.depth` must now be mocked.

I would further note that at some point in time in the future, I need to not mock `fl_directory_do()` and instead call that directly and mocks its calls.
This is a complex situation that would require mocking the directory list and several other things.
This is too much work to do at this time.

The updated unit tests exposed a concern regarding immediately exiting the pre-process after an "is file type" check.
Move this down to the end of the pre-process to allow for other checks to happen.
I have some concerns with doing this for additional behavior and I will need to review and test other programs.
(That is, the `rmdir` vs `rm` vs `unlink` behavior are directly tied to "is file type" checks.)
I'd rather not make this commit any larger than it already is and so I am leaving the further investigation and changes to another time.

42 files changed:
data/build/remove/settings-mocks.remove
data/build/remove/settings-tests.remove
data/build/remove/settings.remove
data/build/remove/settings.rm
data/build/remove/settings.rmdir
data/build/remove/settings.unlink
data/build/stand_alone/configs/remove-config.h
sources/c/program/kevux/tools/remove/main/common.h
sources/c/program/kevux/tools/remove/main/common/define.h
sources/c/program/kevux/tools/remove/main/common/print.c
sources/c/program/kevux/tools/remove/main/common/print.h
sources/c/program/kevux/tools/remove/main/common/string.c
sources/c/program/kevux/tools/remove/main/common/string.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/debug.c
sources/c/program/kevux/tools/remove/main/print/debug.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/print/verbose.c
sources/c/program/kevux/tools/remove/main/print/verbose.h
sources/c/program/kevux/tools/remove/main/remove.c
tests/unit/remove/c/mock-remove.c
tests/unit/remove/c/mock-remove.h
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-directory_tree_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-regular_no_args.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 1b986df0d2693f48703aae8b2312a33d64067f9a..24f0b40ad16278022249df4b3aa679892815862c 100644 (file)
@@ -30,10 +30,16 @@ build_language c
 
 build_libraries -lc
 build_libraries-individual -lfll_error -lfll_print -lfll_program
-build_libraries-individual -lfl_conversion -lfl_directory -lfl_print
+build_libraries-individual -lfl_conversion -lfl_directory -lfl_path -lfl_print
 build_libraries-individual -lf_account -lf_color -lf_compare -lf_console -lf_conversion -lf_directory -lf_file -lf_memory -lf_path -lf_pipe -lf_print -lf_rip -lf_signal -lf_string -lf_time -lf_type_array -lf_utf
 build_libraries-individual_thread -lf_thread
 
+build_libraries_static -l:libc.a
+build_libraries_static-individual -l:libfll_error.a -l:libfll_print.a -l:libfll_program.a
+build_libraries_static-individual -l:libfl_conversion.a -l:libfl_directory.a -l:libfl_path.a -l:libfl_print.a
+build_libraries_static-individual -l:libf_account.a -l:libf_color.a -l:libf_compare.a -l:libf_console.a -l:libf_conversion.a -l:libf_directory.a -l:libf_file.a -l:libf_memory.a -l:libf_path.a -l:libf_pipe.a -l:libf_print.a -l:libf_rip.a -l:libf_signal.a -l:libf_string.a -l:libf_time.a -l:libf_type_array.a -l:libf_utf.a
+build_libraries_static-individual_thread -l:libf_thread.a
+
 build_sources_library remove.c main.c string.c
 build_sources_library ../../../../../../../tests/unit/remove/c/mock-remove.c
 
@@ -89,6 +95,7 @@ flags -Wl,--wrap=f_account_group_id_by_name
 flags -Wl,--wrap=f_account_id_by_name
 flags -Wl,--wrap=f_directory_empty
 flags -Wl,--wrap=f_directory_remove
+flags -Wl,--wrap=f_file_access
 flags -Wl,--wrap=f_file_exists
 flags -Wl,--wrap=f_file_is
 flags -Wl,--wrap=f_file_remove
index e7d84ce6e40dadd488a7843e37e21ea0447a6e37..bef8d66c2a1ee067dd40c3b8c9177da8ef9c76d8 100644 (file)
@@ -29,6 +29,12 @@ build_libraries-individual -lfl_conversion -lfl_directory -lfl_path -lfl_print
 build_libraries-individual -lf_account -lf_color -lf_compare -lf_console -lf_conversion -lf_directory -lf_file -lf_memory -lf_path -lf_pipe -lf_print -lf_rip -lf_signal -lf_string -lf_time -lf_type_array -lf_utf
 build_libraries-individual_thread -lf_thread
 
+build_libraries_static -l:libc.a
+build_libraries_static-individual -l:libfll_error.a -l:libfll_print.a -l:libfll_program.a
+build_libraries_static-individual -l:libfl_conversion.a -l:libfl_directory.a -l:libfl_path.a -l:libfl_print.a
+build_libraries_static-individual -l:libf_account.a -l:libf_color.a -l:libf_compare.a -l:libf_console.a -l:libf_conversion.a -l:libf_directory.a -l:libf_file.a -l:libf_memory.a -l:libf_path.a -l:libf_pipe.a -l:libf_print.a -l:libf_rip.a -l:libf_signal.a -l:libf_string.a -l:libf_time.a -l:libf_type_array.a -l:libf_utf.a
+build_libraries_static-individual_thread -l:libf_thread.a
+
 build_sources_program test-remove.c
 build_sources_program test-remove-date_accessed.c test-remove-date_changed.c test-remove-date_updated.c
 build_sources_program test-remove-directory_no_args.c test-remove-directory_recurse_simple.c test-remove-directory_tree_simple.c
index 473fa4c80c06f0aeedfd1f3f4b810d7483218c32..8909b2fce039b7319b8d93ec1304c6ee4afd316a 100644 (file)
@@ -38,14 +38,14 @@ build_language c
 
 build_libraries_shared -lc -lremove
 build_libraries_shared-individual -lfll_error -lfll_print -lfll_program
-build_libraries_shared-individual -lfl_conversion -lfl_directory -lfl_print
+build_libraries_shared-individual -lfl_conversion -lfl_directory -lfl_path -lfl_print
 build_libraries_shared-individual -lf_account -lf_color -lf_compare -lf_console -lf_conversion -lf_directory -lf_file -lf_memory -lf_path -lf_pipe -lf_print -lf_rip -lf_signal -lf_string -lf_time -lf_type_array -lf_utf
 build_libraries_shared-individual_thread -lf_thread
 build_libraries_shared-level -lfll_2 -lfll_1 -lfll_0
 build_libraries_shared-monolithic -lfll
 
 build_libraries_static -l:libc.a -l:libremove.a
-build_libraries_static-individual -l:libfll_error.a -l:libfll_print.a -l:libfll_program.a
+build_libraries_static-individual -l:libfll_error.a -l:libfll_print.a -l:libfl_path.a -l:libfll_program.a
 build_libraries_static-individual -l:libfl_conversion.a -l:libfl_directory.a -l:libfl_print.a
 build_libraries_static-individual -l:libf_account.a -l:libf_color.a -l:libf_compare.a -l:libf_console.a -l:libf_conversion.a -l:libf_directory.a -l:libf_file.a -l:libf_memory.a -l:libf_path.a -l:libf_pipe.a -l:libf_print.a -l:libf_rip.a -l:libf_signal.a -l:libf_string.a -l:libf_time.a -l:libf_type_array.a -l:libf_utf.a
 build_libraries_static-individual_thread -l:libf_thread.a
index 911fec60426c23fc31a51870f853785702d99543..59ee03cf6994033fa1586228fa819cb93d5fe588 100644 (file)
@@ -38,7 +38,7 @@ build_language c
 
 build_libraries_shared -lc -lremove
 build_libraries_shared-individual -lfll_error -lfll_print -lfll_program
-build_libraries_shared-individual -lfl_conversion -lfl_directory -lfl_print
+build_libraries_shared-individual -lfl_conversion -lfl_directory -lfl_path -lfl_print
 build_libraries_shared-individual -lf_account -lf_color -lf_compare -lf_console -lf_conversion -lf_directory -lf_file -lf_memory -lf_path -lf_pipe -lf_print -lf_rip -lf_signal -lf_string -lf_time -lf_type_array -lf_utf
 build_libraries_shared-individual_thread -lf_thread
 build_libraries_shared-level -lfll_2 -lfll_1 -lfll_0
@@ -46,7 +46,7 @@ build_libraries_shared-monolithic -lfll
 
 build_libraries_static -l:libc.a -l:libremove.a
 build_libraries_static-individual -l:libfll_error.a -l:libfll_print.a -l:libfll_program.a
-build_libraries_static-individual -l:libfl_conversion.a -l:libfl_directory.a -l:libfl_print.a
+build_libraries_static-individual -l:libfl_conversion.a -l:libfl_directory.a -l:libfl_path.a -l:libfl_print.a
 build_libraries_static-individual -l:libf_account.a -l:libf_color.a -l:libf_compare.a -l:libf_console.a -l:libf_conversion.a -l:libf_directory.a -l:libf_file.a -l:libf_memory.a -l:libf_path.a -l:libf_pipe.a -l:libf_print.a -l:libf_rip.a -l:libf_signal.a -l:libf_string.a -l:libf_time.a -l:libf_type_array.a -l:libf_utf.a
 build_libraries_static-individual_thread -l:libf_thread.a
 build_libraries_static-level -l:libfll_2.a -l:libfll_1.a -l:libfll_0.a
index ab044253dc8f8a3a8769c89af1634616e6055c95..11214682130e6e52b6420059f9cf37ea852fdf6a 100644 (file)
@@ -38,7 +38,7 @@ build_language c
 
 build_libraries_shared -lc -lremove
 build_libraries_shared-individual -lfll_error -lfll_print -lfll_program
-build_libraries_shared-individual -lfl_conversion -lfl_directory -lfl_print
+build_libraries_shared-individual -lfl_conversion -lfl_directory -lfl_path -lfl_print
 build_libraries_shared-individual -lf_account -lf_color -lf_compare -lf_console -lf_conversion -lf_directory -lf_file -lf_memory -lf_path -lf_pipe -lf_print -lf_rip -lf_signal -lf_string -lf_time -lf_type_array -lf_utf
 build_libraries_shared-individual_thread -lf_thread
 build_libraries_shared-level -lfll_2 -lfll_1 -lfll_0
@@ -46,7 +46,7 @@ build_libraries_shared-monolithic -lfll
 
 build_libraries_static -l:libc.a -l:libremove.a
 build_libraries_static-individual -l:libfll_error.a -l:libfll_print.a -l:libfll_program.a
-build_libraries_static-individual -l:libfl_conversion.a -l:libfl_directory.a -l:libfl_print.a
+build_libraries_static-individual -l:libfl_conversion.a -l:libfl_directory.a -l:libfl_path.a -l:libfl_print.a
 build_libraries_static-individual -l:libf_account.a -l:libf_color.a -l:libf_compare.a -l:libf_console.a -l:libf_conversion.a -l:libf_directory.a -l:libf_file.a -l:libf_memory.a -l:libf_path.a -l:libf_pipe.a -l:libf_print.a -l:libf_rip.a -l:libf_signal.a -l:libf_string.a -l:libf_time.a -l:libf_type_array.a -l:libf_utf.a
 build_libraries_static-individual_thread -l:libf_thread.a
 build_libraries_static-level -l:libfll_2.a -l:libfll_1.a -l:libfll_0.a
index 4c043b0bf338a8a9f91172525ab55e36cd69950b..21c244599781ee4ac706dbb1bf6254ee515c23e6 100644 (file)
@@ -38,7 +38,7 @@ build_language c
 
 build_libraries_shared -lc -lremove
 build_libraries_shared-individual -lfll_error -lfll_print -lfll_program
-build_libraries_shared-individual -lfl_conversion -lfl_directory -lfl_print
+build_libraries_shared-individual -lfl_conversion -lfl_directory -lfl_path -lfl_print
 build_libraries_shared-individual -lf_account -lf_color -lf_compare -lf_console -lf_conversion -lf_directory -lf_file -lf_memory -lf_path -lf_pipe -lf_print -lf_rip -lf_signal -lf_string -lf_time -lf_type_array -lf_utf
 build_libraries_shared-individual_thread -lf_thread
 build_libraries_shared-level -lfll_2 -lfll_1 -lfll_0
@@ -46,7 +46,7 @@ build_libraries_shared-monolithic -lfll
 
 build_libraries_static -l:libc.a -l:libremove.a
 build_libraries_static-individual -l:libfll_error.a -l:libfll_print.a -l:libfll_program.a
-build_libraries_static-individual -l:libfl_conversion.a -l:libfl_directory.a -l:libfl_print.a
+build_libraries_static-individual -l:libfl_conversion.a -l:libfl_directory.a -l:libfl_path.a -l:libfl_print.a
 build_libraries_static-individual -l:libf_account.a -l:libf_color.a -l:libf_compare.a -l:libf_console.a -l:libf_conversion.a -l:libf_directory.a -l:libf_file.a -l:libf_memory.a -l:libf_path.a -l:libf_pipe.a -l:libf_print.a -l:libf_rip.a -l:libf_signal.a -l:libf_string.a -l:libf_time.a -l:libf_type_array.a -l:libf_utf.a
 build_libraries_static-individual_thread -l:libf_thread.a
 build_libraries_static-level -l:libfll_2.a -l:libfll_1.a -l:libfll_0.a
index b5110cb8b3176ae1f333160def9ccf6640513f27..9d2a76b37f5f6cfcef85dcee6d0f13b1f1b588ac 100644 (file)
 #define _di_f_date_t_
 #define _di_f_directory_at_d_
 //#define _di_f_directory_back_s_
-//#define _di_f_directory_stream_close_
 //#define _di_f_directory_compare_call_t_
 #define _di_f_directory_create_
 #define _di_f_directory_create_at_
 //#define _di_f_directory_current_s_
+//#define _di_f_directory_empty_
 //#define _di_f_directory_entity_t_
 //#define _di_f_directory_exists_
 #define _di_f_directory_exists_at_
 #define _di_f_directory_recurse_doss_t_
 //#define _di_f_directory_remove_
 #define _di_f_directory_remove_custom_
-//#define _di_f_directory_stream_close_
-//#define _di_f_directory_stream_open_
-#define _di_f_directory_stream_open_id_
-//#define _di_f_directory_stream_read_
-#define _di_f_directory_stream_rewind_
-#define _di_f_directory_stream_seek_
-#define _di_f_directory_stream_tell_
 //#define _di_f_directory_s_
 #define _di_f_directory_status_delete_
 #define _di_f_directory_status_destroy_
 #define _di_f_directory_statusss_delete_callback_
 #define _di_f_directory_statusss_destroy_callback_
 #define _di_f_directory_statusss_t_
+//#define _di_f_directory_stream_close_
+//#define _di_f_directory_stream_open_
+#define _di_f_directory_stream_open_id_
+//#define _di_f_directory_stream_read_
+#define _di_f_directory_stream_rewind_
+#define _di_f_directory_stream_seek_
+//#define _di_f_directory_stream_t_
+#define _di_f_directory_stream_tell_
 #define _di_f_directory_touch_
 #define _di_f_directory_touch_at_
-#define _di_f_f_utf_space_em_per_four_s_
-#define _di_f_f_utf_space_em_per_six_s_
-#define _di_f_f_utf_space_em_per_three_s_
-#define _di_f_f_utf_space_em_quad_s_
-#define _di_f_f_utf_space_em_s_
-#define _di_f_f_utf_space_en_quad_s_
-#define _di_f_f_utf_space_en_s_
-#define _di_f_f_utf_space_figure_s_
-#define _di_f_f_utf_space_hair_s_
-#define _di_f_f_utf_space_ideographic_s_
-#define _di_f_f_utf_space_line_feed_reverse_s_
-#define _di_f_f_utf_space_line_next_s_
-#define _di_f_f_utf_space_medium_mathematical_s_
-#define _di_f_f_utf_space_no_break_narrow_s_
-#define _di_f_f_utf_space_no_break_s_
-#define _di_f_f_utf_space_ogham_s_
-#define _di_f_f_utf_space_punctuation_s_
-#define _di_f_f_utf_space_separator_line_s_
-#define _di_f_f_utf_space_separator_paragraph_s_
-#define _di_f_f_utf_space_thin_s_
-#define _di_f_f_utf_substitute_middle_dot_s_
-#define _di_f_f_utf_substitute_open_box_s_
-#define _di_f_f_utf_substitute_open_box_shouldered_s_
-#define _di_f_f_utf_substitute_symbol_blank_s_
-#define _di_f_f_utf_substitute_symbol_space_s_
-#define _di_f_file_access_
+//#define _di_f_file_access_
 #define _di_f_file_access_at_
-#define _di_f_file_access_mode_d_
+//#define _di_f_file_access_mode_d_
 #define _di_f_file_at_d_
 #define _di_f_file_clone_
 //#define _di_f_file_close_
 //#define _di_f_file_open_mode_s_
 //#define _di_f_file_open_mode_write_append_s_
 //#define _di_f_file_open_mode_write_truncate_s_
-#define _di_f_file_operation_access_s_
+//#define _di_f_file_operation_access_s_
 #define _di_f_file_operation_analyze_s_
 #define _di_f_file_operation_append_s_
 #define _di_f_file_operation_change_group_s_
 #define _di_f_file_operation_touch_s_
 #define _di_f_file_operation_truncate_s_
 #define _di_f_file_operation_unlink_s_
-#define _di_f_file_operation_verify_s_
+//#define _di_f_file_operation_verify_s_
 #define _di_f_file_operation_wipe_s_
 #define _di_f_file_operation_write_s_
 #define _di_f_file_owner_read_
 //#define _di_f_gid_t_
 //#define _di_f_gids_t_
 #define _di_f_gidss_delete_callback_
-#define _di_f_gidss_destroy_callback_
 #define _di_f_gidss_t_
 //#define _di_f_id_t_
 //#define _di_f_ids_t_
 #define _di_f_idss_delete_callback_
-#define _di_f_idss_destroy_callback_
 #define _di_f_idss_t_
 //#define _di_f_int128_t_
 #define _di_f_int128s_t_
 //#define _di_f_string_ascii_7_s_
 //#define _di_f_string_ascii_8_s_
 //#define _di_f_string_ascii_9_s_
-//#define _di_f_string_ascii_A_s_
-//#define _di_f_string_ascii_B_s_
-//#define _di_f_string_ascii_C_s_
-//#define _di_f_string_ascii_D_s_
-//#define _di_f_string_ascii_E_s_
-//#define _di_f_string_ascii_F_s_
-//#define _di_f_string_ascii_G_s_
-#define _di_f_string_ascii_H_s_
-//#define _di_f_string_ascii_I_s_
-#define _di_f_string_ascii_J_s_
-#define _di_f_string_ascii_K_s_
-//#define _di_f_string_ascii_L_s_
-#define _di_f_string_ascii_M_s_
-//#define _di_f_string_ascii_N_s_
-//#define _di_f_string_ascii_O_s_
-#define _di_f_string_ascii_P_s_
-//#define _di_f_string_ascii_Q_s_
-//#define _di_f_string_ascii_R_s_
-//#define _di_f_string_ascii_S_s_
-//#define _di_f_string_ascii_T_s_
-//#define _di_f_string_ascii_U_s_
-#define _di_f_string_ascii_V_s_
-//#define _di_f_string_ascii_W_s_
-//#define _di_f_string_ascii_X_s_
-//#define _di_f_string_ascii_Y_s_
-//#define _di_f_string_ascii_Z_s_
 //#define _di_f_string_ascii_a_s_
+//#define _di_f_string_ascii_A_s_
 #define _di_f_string_ascii_acknowledge_negative_s_
 #define _di_f_string_ascii_acknowledge_s_
 //#define _di_f_string_ascii_ampersand_s_
 //#define _di_f_string_ascii_asterisk_s_
 //#define _di_f_string_ascii_b_s_
+//#define _di_f_string_ascii_B_s_
 #define _di_f_string_ascii_bell_s_
 //#define _di_f_string_ascii_brace_close_s_
 //#define _di_f_string_ascii_brace_open_s_
 //#define _di_f_string_ascii_bracket_close_s_
 //#define _di_f_string_ascii_bracket_open_s_
 //#define _di_f_string_ascii_c_s_
+//#define _di_f_string_ascii_C_s_
 #define _di_f_string_ascii_cancel_s_
 //#define _di_f_string_ascii_caret_s_
 //#define _di_f_string_ascii_colon_s_
 //#define _di_f_string_ascii_colon_semi_s_
 //#define _di_f_string_ascii_comma_s_
 //#define _di_f_string_ascii_d_s_
+//#define _di_f_string_ascii_D_s_
 #define _di_f_string_ascii_data_link_escape_s_
 #define _di_f_string_ascii_device_control_four_s_
 #define _di_f_string_ascii_device_control_one_s_
 #define _di_f_string_ascii_device_control_three_s_
 #define _di_f_string_ascii_device_control_two_s_
 //#define _di_f_string_ascii_dollar_s_
+//#define _di_f_string_ascii_E_s_
 //#define _di_f_string_ascii_e_s_
 #define _di_f_string_ascii_enquiry_s_
 //#define _di_f_string_ascii_equal_s_
 #define _di_f_string_ascii_escape_s_
 //#define _di_f_string_ascii_exclamation_s_
 //#define _di_f_string_ascii_f_s_
+//#define _di_f_string_ascii_F_s_
 #define _di_f_string_ascii_feed_form_s_
 //#define _di_f_string_ascii_feed_line_s_
 //#define _di_f_string_ascii_g_s_
+//#define _di_f_string_ascii_G_s_
 //#define _di_f_string_ascii_grave_s_
 #define _di_f_string_ascii_h_s_
+#define _di_f_string_ascii_H_s_
 #define _di_f_string_ascii_header_start_s_
 //#define _di_f_string_ascii_i_s_
+//#define _di_f_string_ascii_I_s_
 #define _di_f_string_ascii_j_s_
+#define _di_f_string_ascii_J_s_
 #define _di_f_string_ascii_k_s_
+#define _di_f_string_ascii_K_s_
 //#define _di_f_string_ascii_l_s_
+//#define _di_f_string_ascii_L_s_
 #define _di_f_string_ascii_m_s_
+#define _di_f_string_ascii_M_s_
 #define _di_f_string_ascii_mark_question_s_
 #define _di_f_string_ascii_medium_stop_s_
 //#define _di_f_string_ascii_minus_s_
 //#define _di_f_string_ascii_n_s_
+//#define _di_f_string_ascii_N_s_
 #define _di_f_string_ascii_null_s_
 //#define _di_f_string_ascii_o_s_
+//#define _di_f_string_ascii_O_s_
 #define _di_f_string_ascii_p_s_
+#define _di_f_string_ascii_P_s_
 #define _di_f_string_ascii_parenthesis_close_s_
 #define _di_f_string_ascii_parenthesis_open_s_
 //#define _di_f_string_ascii_percent_s_
 //#define _di_f_string_ascii_plus_s_
 //#define _di_f_string_ascii_pound_s_
 //#define _di_f_string_ascii_q_s_
+//#define _di_f_string_ascii_Q_s_
 //#define _di_f_string_ascii_quote_double_s_
 //#define _di_f_string_ascii_quote_single_s_
 //#define _di_f_string_ascii_r_s_
+//#define _di_f_string_ascii_R_s_
 #define _di_f_string_ascii_return_carriage_s_
 //#define _di_f_string_ascii_s_
 //#define _di_f_string_ascii_s_s_
+//#define _di_f_string_ascii_S_s_
 #define _di_f_string_ascii_separator_file_s_
 #define _di_f_string_ascii_separator_group_s_
 #define _di_f_string_ascii_separator_record_s_
 #define _di_f_string_ascii_substitute_s_
 #define _di_f_string_ascii_synchronous_idle_s_
 //#define _di_f_string_ascii_t_s_
+//#define _di_f_string_ascii_T_s_
 #define _di_f_string_ascii_tab_horizontal_s_
 #define _di_f_string_ascii_tab_vertical_s_
 #define _di_f_string_ascii_text_start_s_
 #define _di_f_string_ascii_transmission_block_end_s_
 #define _di_f_string_ascii_transmission_stop_s_
 //#define _di_f_string_ascii_u_s_
+//#define _di_f_string_ascii_U_s_
 //#define _di_f_string_ascii_underscore_s_
 #define _di_f_string_ascii_v_s_
+#define _di_f_string_ascii_V_s_
 //#define _di_f_string_ascii_w_s_
+//#define _di_f_string_ascii_W_s_
 //#define _di_f_string_ascii_x_s_
+//#define _di_f_string_ascii_X_s_
 //#define _di_f_string_ascii_y_s_
+//#define _di_f_string_ascii_Y_s_
 //#define _di_f_string_ascii_z_s_
+//#define _di_f_string_ascii_Z_s_
 #define _di_f_string_constant_t_
 #define _di_f_string_dynamic_append_
 //#define _di_f_string_dynamic_append_assure_
 #define _di_f_string_dynamicss_t_
 //#define _di_f_string_empty_s_
 //#define _di_f_string_eol_s_
-#define _di_f_string_format_C_s_
-#define _di_f_string_format_DL_double_s_
-#define _di_f_string_format_DL_s_
-#define _di_f_string_format_DL_single_s_
-#define _di_f_string_format_D_double_s_
-#define _di_f_string_format_D_s_
-#define _di_f_string_format_D_single_s_
-#define _di_f_string_format_III_s_
-#define _di_f_string_format_II_s_
-#define _di_f_string_format_ILL_s_
-#define _di_f_string_format_IL_s_
-#define _di_f_string_format_IN_s_
-#define _di_f_string_format_I_s_
-#define _di_f_string_format_QQ_double_s_
-//#define _di_f_string_format_QQ_single_s_
-#define _di_f_string_format_Q_double_s_
-#define _di_f_string_format_Q_range_double_s_
-#define _di_f_string_format_Q_range_single_s_
-#define _di_f_string_format_Q_s_
-//#define _di_f_string_format_Q_single_s_
-#define _di_f_string_format_RR_double_s_
-#define _di_f_string_format_RR_single_s_
-#define _di_f_string_format_R_double_s_
-#define _di_f_string_format_R_range_double_s_
-#define _di_f_string_format_R_range_single_s_
-#define _di_f_string_format_R_s_
-#define _di_f_string_format_R_single_s_
-#define _di_f_string_format_SS_double_s_
-#define _di_f_string_format_SS_single_s_
-#define _di_f_string_format_S_double_s_
-#define _di_f_string_format_S_s_
-//#define _di_f_string_format_S_single_s_
-#define _di_f_string_format_UII_s_
-#define _di_f_string_format_UI_s_
-#define _di_f_string_format_ULL_s_
-#define _di_f_string_format_UL_s_
-#define _di_f_string_format_UN_s_
-#define _di_f_string_format_U_s_
-#define _di_f_string_format_Z_double_s_
-#define _di_f_string_format_Z_s_
-#define _di_f_string_format_Z_single_s_
 //#define _di_f_string_format_bracket_close_s_
 #define _di_f_string_format_bracket_open_s_
 #define _di_f_string_format_c_s_
-#define _di_f_string_format_d_double_s_
+#define _di_f_string_format_C_s_
 #define _di_f_string_format_d_s_
+#define _di_f_string_format_D_s_
+#define _di_f_string_format_d_double_s_
+#define _di_f_string_format_D_double_s_
 #define _di_f_string_format_d_single_s_
+#define _di_f_string_format_D_single_s_
 #define _di_f_string_format_dl_double_s_
+#define _di_f_string_format_DL_double_s_
 #define _di_f_string_format_dl_s_
+#define _di_f_string_format_DL_s_
 #define _di_f_string_format_dl_single_s_
-#define _di_f_string_format_i_double_s_
+#define _di_f_string_format_DL_single_s_
 #define _di_f_string_format_i_s_
+#define _di_f_string_format_I_s_
+#define _di_f_string_format_i_double_s_
 //#define _di_f_string_format_i_single_s_
 #define _di_f_string_format_ii_double_s_
 #define _di_f_string_format_ii_s_
+#define _di_f_string_format_II_s_
 #define _di_f_string_format_ii_single_s_
+#define _di_f_string_format_il_s_
+#define _di_f_string_format_IL_s_
+#define _di_f_string_format_il_double_s_
+#define _di_f_string_format_il_single_s_
+#define _di_f_string_format_in_double_s_
+#define _di_f_string_format_in_s_
+#define _di_f_string_format_IN_s_
+#define _di_f_string_format_in_single_s_
 #define _di_f_string_format_iii_double_s_
 #define _di_f_string_format_iii_s_
+#define _di_f_string_format_III_s_
 #define _di_f_string_format_iii_single_s_
-#define _di_f_string_format_il_double_s_
-#define _di_f_string_format_il_s_
-#define _di_f_string_format_il_single_s_
 #define _di_f_string_format_ill_double_s_
 #define _di_f_string_format_ill_s_
+#define _di_f_string_format_ILL_s_
 #define _di_f_string_format_ill_single_s_
-#define _di_f_string_format_in_double_s_
-#define _di_f_string_format_in_s_
-#define _di_f_string_format_in_single_s_
+#define _di_f_string_format_q_s_
+//#define _di_f_string_format_Q_s_
 #define _di_f_string_format_q_double_s_
+#define _di_f_string_format_Q_double_s_
 #define _di_f_string_format_q_range_double_s_
+#define _di_f_string_format_Q_range_double_s_
 #define _di_f_string_format_q_range_single_s_
-#define _di_f_string_format_q_s_
+#define _di_f_string_format_Q_range_single_s_
 //#define _di_f_string_format_q_single_s_
+//#define _di_f_string_format_Q_single_s_
+#define _di_f_string_format_QQ_double_s_
+//#define _di_f_string_format_QQ_single_s_
+#define _di_f_string_format_r_s_
+#define _di_f_string_format_R_s_
 #define _di_f_string_format_r_double_s_
+#define _di_f_string_format_R_double_s_
 #define _di_f_string_format_r_range_double_s_
+#define _di_f_string_format_R_range_double_s_
 #define _di_f_string_format_r_range_single_s_
-#define _di_f_string_format_r_s_
+#define _di_f_string_format_R_range_single_s_
 //#define _di_f_string_format_r_single_s_
+#define _di_f_string_format_R_single_s_
 #define _di_f_string_format_rr_double_s_
+#define _di_f_string_format_RR_double_s_
 //#define _di_f_string_format_rr_single_s_
+#define _di_f_string_format_RR_single_s_
 //#define _di_f_string_format_s_
 #define _di_f_string_format_s_double_s_
+#define _di_f_string_format_S_double_s_
 #define _di_f_string_format_s_s_
+#define _di_f_string_format_S_s_
 #define _di_f_string_format_s_single_s_
+//#define _di_f_string_format_S_single_s_
 #define _di_f_string_format_sentence_end_double_quote_s_
 #define _di_f_string_format_sentence_end_double_s_
 //#define _di_f_string_format_sentence_end_quote_s_
 //#define _di_f_string_format_sentence_end_single_quote_s_
 //#define _di_f_string_format_sentence_end_single_s_
 #define _di_f_string_format_ss_double_s_
+#define _di_f_string_format_SS_double_s_
 #define _di_f_string_format_ss_single_s_
+#define _di_f_string_format_SS_single_s_
 #define _di_f_string_format_u_double_s_
 #define _di_f_string_format_u_s_
+#define _di_f_string_format_U_s_
 //#define _di_f_string_format_u_single_s_
 #define _di_f_string_format_ui_double_s_
 #define _di_f_string_format_ui_s_
+#define _di_f_string_format_UI_s_
 //#define _di_f_string_format_ui_single_s_
 #define _di_f_string_format_uii_double_s_
 #define _di_f_string_format_uii_s_
+#define _di_f_string_format_UII_s_
 #define _di_f_string_format_uii_single_s_
 #define _di_f_string_format_uii_single_s_ULL
 #define _di_f_string_format_ul_double_s_
 #define _di_f_string_format_ul_s_
+#define _di_f_string_format_UL_s_
 #define _di_f_string_format_ul_single_s_
 #define _di_f_string_format_ull_double_s_
 #define _di_f_string_format_ull_s_
+#define _di_f_string_format_ULL_s_
 #define _di_f_string_format_ull_single_s_
 #define _di_f_string_format_un_double_s_
 #define _di_f_string_format_un_s_
+#define _di_f_string_format_UN_s_
 //#define _di_f_string_format_un_single_s_
 #define _di_f_string_format_z_double_s_
+#define _di_f_string_format_Z_double_s_
 #define _di_f_string_format_z_s_
+#define _di_f_string_format_Z_s_
 #define _di_f_string_format_z_single_s_
+#define _di_f_string_format_Z_single_s_
 #define _di_f_string_map_multi_t_
 #define _di_f_string_map_multis_append_
 #define _di_f_string_map_multis_append_all_
 //#define _di_f_type_sizes_d_
 //#define _di_f_uid_t_
 //#define _di_f_uids_t_
-#define _di_f_uidss_delete_callback_
 #define _di_f_uidss_destroy_callback_
 #define _di_f_uidss_t_
 //#define _di_f_uint128_t_
 #define _di_f_utf_string_prepend_assure_nulless_
 #define _di_f_utf_string_prepend_nulless_
 #define _di_f_utf_string_seek_line_
+#define _di_f_utf_string_seek_line_back
 #define _di_f_utf_string_seek_line_back_
 #define _di_f_utf_string_seek_line_to_
 #define _di_f_utf_string_seek_line_to_back_
 #define _di_f_utf_unicode_to_
 #define _di_f_utf_width_e_
 #define _di_f_void_call_t_
+//#define _di_f_void_pointer_call_t_
 //#define _di_fl_conversion_data_base_10_c_
 #define _di_fl_conversion_data_base_12_c_
 #define _di_fl_conversion_data_base_16_c_
 #define _di_fl_directory_path_pop_
 #define _di_fl_directory_path_push_
 #define _di_fl_directory_path_push_dynamic_
+#define _di_fl_path_canonical_
+//#define _di_fl_path_clean_
 #define _di_fl_print_call_t_
 //#define _di_fl_print_debug_s_
 //#define _di_fl_print_error_s_
 //#define _di_fl_print_warning_s_
 //#define _di_fll_error_file_flag_e_
 //#define _di_fll_error_file_print_
+#define _di_fll_error_file_print_one_
+#define _di_fll_error_file_print_simple_
 //#define _di_fll_error_file_type_directory_s_
 //#define _di_fll_error_file_type_e_
 //#define _di_fll_error_file_type_file_s_
 //#define _di_fll_error_file_type_socket_s_
 #define _di_fll_error_parameter_integer_print_
 //#define _di_fll_error_print_
+//#define _di_fll_error_s_a_
+//#define _di_fll_error_s_e_
 #define _di_fll_print_
 #define _di_fll_print_character_
 #define _di_fll_print_character_safely_
 #define _di_fll_program_print_error_parameter_must_specify_once_value_
 #define _di_fll_program_print_error_parameter_process_
 #define _di_fll_program_print_error_parameter_range_start_before_stop_
+//#define _di_fll_program_print_error_parameter_support_not_
 #define _di_fll_program_print_error_parameter_value_too_long_
 #define _di_fll_program_print_error_pipe_invalid_form_feed_
 #define _di_fll_program_print_error_pipe_missing_content_
index 34f783d327993082f7a8a36dc80598ed8a457a24..d0fcc12ee89f96d6eebc62645377602eecc87728 100644 (file)
@@ -34,7 +34,7 @@ extern "C" {
  *     F_okay on success.
  *     F_data_not on success but nothing was provided to operate with.
  *
- *     F_parameter (with error bit) on parameter error.
+ *     F_parameter (with error bit) on invalid parameter.
  *
  *     Errors (with error bit) from: f_console_parameter_process().
  *     Errors (with error bit) from: f_file_stream_open().
@@ -132,7 +132,7 @@ extern "C" {
  *     F_okay on success.
  *     F_data_not on success but nothing was provided to operate with.
  *
- *     F_parameter (with error bit) on parameter error.
+ *     F_parameter (with error bit) on invalid parameter.
  *
  *     Errors (with error bit) from: f_console_parameter_process().
  *     Errors (with error bit) from: fll_program_parameter_process_context().
index a4b04b96b06529cc4c88346459f34d93fa92c237..94b3be8b62af83ccf290a37207ec921d4e7546c4 100644 (file)
@@ -167,6 +167,13 @@ extern "C" {
  *   - simulate_not:     Simulate printing is explicitly disabled for the specific file.
  *   - top:              Designate that this is a top-level directory file.
  *   - top_similate_not: Helper used to designate both simulate_not and top being set.
+ *   - unable_execute:   Designate that the file cannot be executed (only matters for directories).
+ *   - unable_read:      Designate that the file cannot be read (may prevent accessing information).
+ *   - unable_rw:        Helper used to designate unable_read and unable_write being set.
+ *   - unable_rwx:       Helper used to designate unable_execute, unable_read, and unable_write being set.
+ *   - unable_rx:        Helper used to designate unable_read and unable_execute being set.
+ *   - unable_write:     Designate that the file cannot be written to (may prevent delete).
+ *   - unable_wx:        Helper used to designate unable_execute and unable_write being set.
  */
 #ifndef _di_kt_remove_flag_operate_d_
   #define kt_remove_flag_operate_none_d             0x0
@@ -184,6 +191,13 @@ extern "C" {
   #define kt_remove_flag_operate_simulate_not_d     0x400
   #define kt_remove_flag_operate_top_d              0x800
   #define kt_remove_flag_operate_top_simulate_not_d 0xc00
+  #define kt_remove_flag_operate_unable_execute_d   0x1000
+  #define kt_remove_flag_operate_unable_read_d      0x2000
+  #define kt_remove_flag_operate_unable_rw_d        0x6000
+  #define kt_remove_flag_operate_unable_rwx_d       0x7000
+  #define kt_remove_flag_operate_unable_rx_d        0x3000
+  #define kt_remove_flag_operate_unable_write_d     0x4000
+  #define kt_remove_flag_operate_unable_wx_d        0x5000
 #endif // _di_kt_remove_flag_operate_d_
 
 /**
@@ -208,18 +222,12 @@ extern "C" {
  * A set of flags used internally in the directory recursion process.
  *
  * kt_remove_flag_recurse_*_d:
- *   - none:          No directory recursion being performed.
- *   - normal:        Normal directory recursion.
- *   - normal_parent: Helper flag representing both normal and parent flags being set.
- *   - parent:        Directory recursion, representing the parent directory being recursed.
- *   - top:           Path is a top level (before any potential recursion is performed).
+ *   - none:   No directory recursion being performed.
+ *   - active: Normal directory recursion is active.
  */
 #ifndef _di_kt_remove_flag_recurse_d_
-  #define kt_remove_flag_recurse_none_d          0x0
-  #define kt_remove_flag_recurse_normal_d        0x1
-  #define kt_remove_flag_recurse_normal_parent_d 0x3
-  #define kt_remove_flag_recurse_parent_d        0x2
-  #define kt_remove_flag_recurse_top_d           0x4
+  #define kt_remove_flag_recurse_none_d   0x0
+  #define kt_remove_flag_recurse_active_d 0x1
 #endif // _di_kt_remove_flag_recurse_d_
 
 /**
@@ -261,7 +269,7 @@ extern "C" {
  *   - empty_not_fail:              Fail on not empty directories.
  *   - fifo:                        Remove by file type: FIFO.
  *   - fifo_ignore:                 Ignore during simulate file type: FIFO.
- *   - file_types:                  A helper flag representing all file types flags.
+ *   - file_types:                  A helper flag representing all file types flags (block, character, directory, fifo, link, regular, socket, unknown).
  *   - file_types_except_directory: A helper flag representing all file types flags except for the directory type.
  *   - file_types_ignore:           A helper flag representing all file types "ignore" flags.
  *   - follow:                      Follow symbolic links for deleting the file being pointed to rather than the link itself (when not set the link itself is deleted).
@@ -284,6 +292,7 @@ extern "C" {
  *   - regular:                     Remove by file type: regular.
  *   - regular_ignore:              Ignore during simulate file type: regular.
  *   - remember:                    Enable remembering paths already processed.
+ *   - return_fail:                 Designate that the final return state should be a failure, even if there is no error bit set.
  *   - root:                        Allow for deleting root directory (Dangerous!).
  *   - same:                        Remove by same user as caller.
  *   - simulate:                    Do not actually perform deletes, instead print messages (when silent, should still return 0 or 1).
@@ -301,7 +310,7 @@ extern "C" {
 #ifndef _di_kt_remove_main_flag_d_
   #define kt_remove_main_flag_none_d                        0x0
   #define kt_remove_main_flag_accessed_d                    0x1
-  #define kt_remove_main_flag_accessed_changed_updated_d    0x8000000009
+  #define kt_remove_main_flag_accessed_changed_updated_d    0x10000000009
   #define kt_remove_main_flag_block_d                       0x2
   #define kt_remove_main_flag_block_ignore_d                0x4
   #define kt_remove_main_flag_changed_d                     0x8
@@ -318,9 +327,9 @@ extern "C" {
   #define kt_remove_main_flag_empty_not_fail_d              0x2000
   #define kt_remove_main_flag_fifo_d                        0x4000
   #define kt_remove_main_flag_fifo_ignore_d                 0x8000
-  #define kt_remove_main_flag_file_types_d                  0x21040104112
-  #define kt_remove_main_flag_file_types_except_directory_d 0x21040104012
-  #define kt_remove_main_flag_file_types_ignore_d           0x42080208224
+  #define kt_remove_main_flag_file_types_d                  0x42040104112
+  #define kt_remove_main_flag_file_types_except_directory_d 0x42040104012
+  #define kt_remove_main_flag_file_types_ignore_d           0x84080208224
   #define kt_remove_main_flag_follow_d                      0x10000
   #define kt_remove_main_flag_force_d                       0x20000
   #define kt_remove_main_flag_force_simulate_d              0x800020000
@@ -341,19 +350,20 @@ extern "C" {
   #define kt_remove_main_flag_regular_d                     0x40000000
   #define kt_remove_main_flag_regular_ignore_d              0x80000000
   #define kt_remove_main_flag_remember_d                    0x100000000
-  #define kt_remove_main_flag_root_d                        0x200000000
-  #define kt_remove_main_flag_same_d                        0x400000000
-  #define kt_remove_main_flag_simulate_d                    0x800000000
-  #define kt_remove_main_flag_socket_d                      0x1000000000
-  #define kt_remove_main_flag_socket_ignore_d               0x2000000000
-  #define kt_remove_main_flag_tree_d                        0x4000000000
-  #define kt_remove_main_flag_updated_d                     0x8000000000
-  #define kt_remove_main_flag_user_d                        0x10000000000
-  #define kt_remove_main_flag_unknown_d                     0x20000000000
-  #define kt_remove_main_flag_unknown_ignore_d              0x40000000000
-  #define kt_remove_main_flag_utc_d                         0x80000000000
-  #define kt_remove_main_flag_version_d                     0x100000000000
-  #define kt_remove_main_flag_version_copyright_help_d      0x100000080040
+  #define kt_remove_main_flag_return_fail_d                 0x200000000
+  #define kt_remove_main_flag_root_d                        0x400000000
+  #define kt_remove_main_flag_same_d                        0x800000000
+  #define kt_remove_main_flag_simulate_d                    0x1000000000
+  #define kt_remove_main_flag_socket_d                      0x2000000000
+  #define kt_remove_main_flag_socket_ignore_d               0x4000000000
+  #define kt_remove_main_flag_tree_d                        0x8000000000
+  #define kt_remove_main_flag_updated_d                     0x10000000000
+  #define kt_remove_main_flag_user_d                        0x20000000000
+  #define kt_remove_main_flag_unknown_d                     0x40000000000
+  #define kt_remove_main_flag_unknown_ignore_d              0x80000000000
+  #define kt_remove_main_flag_utc_d                         0x100000000000
+  #define kt_remove_main_flag_version_d                     0x200000000000
+  #define kt_remove_main_flag_version_copyright_help_d      0x200000080040
 #endif // _di_kt_remove_main_flag_e_
 
 /**
index 60b247d65de93e9c93dfc4a307e189a26451aef9..2cf7e40b012f0adc19c6219348bdcbe90446a16a 100644 (file)
@@ -8,7 +8,9 @@ extern "C" {
   const f_string_t kt_remove_f_a[] = {
     "f_console_parameter_prioritize_right",
     "f_console_parameter_process",
+    "f_directory_empty",
     "f_directory_remove",
+    "f_file_access",
     "f_file_exists",
     "f_file_link_read",
     "f_file_mode_from_string",
@@ -36,8 +38,12 @@ extern "C" {
     "kt_remove_dates_resize",
     "kt_remove_get_id",
     "kt_remove_modes_resize",
+    "kt_remove_operate_memory_check",
     "kt_remove_operate_memory_save",
+    "kt_remove_operate_recurse",
     "kt_remove_preprocess_file",
+    "kt_remove_preprocess_file_access",
+    "kt_remove_preprocess_file_dates",
     "kt_remove_setting_load",
   };
 #endif // _di_kt_remove_f_a_
index b410ddd9a5838221d617a733d01ff42b2fefa35c..27e5037d0fab7827b8e304e1f5f4a666b98255e0 100644 (file)
@@ -41,7 +41,9 @@ extern "C" {
   enum {
     kt_remove_f_f_console_parameter_prioritize_right_e,
     kt_remove_f_f_console_parameter_process_e,
+    kt_remove_f_f_directory_empty_e,
     kt_remove_f_f_directory_remove_e,
+    kt_remove_f_f_file_access_e,
     kt_remove_f_f_file_exists_e,
     kt_remove_f_f_file_link_read_e,
     kt_remove_f_f_file_mode_from_string_e,
@@ -69,8 +71,12 @@ extern "C" {
     kt_remove_f_kt_remove_dates_resize_e,
     kt_remove_f_kt_remove_get_id_e,
     kt_remove_f_kt_remove_modes_resize_e,
+    kt_remove_f_kt_remove_operate_memory_check_e,
     kt_remove_f_kt_remove_operate_memory_save_e,
+    kt_remove_f_kt_remove_operate_recurse_e,
     kt_remove_f_kt_remove_preprocess_file_e,
+    kt_remove_f_kt_remove_preprocess_file_access_e,
+    kt_remove_f_kt_remove_preprocess_file_dates_e,
     kt_remove_f_kt_remove_setting_load_e,
   }; // enum
 #endif // _di_kt_remove_f_e_
index 7e5b37b481ab63926d791470ada8881553f5ab2f..32b689993fda54eed87ad572bde7a22f4bc87636 100644 (file)
@@ -13,9 +13,11 @@ extern "C" {
 #endif // _di_utf8_program_help_parameters_s_
 
 #ifndef _di_kt_remove_s_
+  const f_string_static_t kt_remove_access_s = macro_f_string_static_t_initialize_1(KT_REMOVE_access_s, 0, KT_REMOVE_access_s_length);
+  const f_string_static_t kt_remove_comma_space_s = macro_f_string_static_t_initialize_1(KT_REMOVE_comma_space_s, 0, KT_REMOVE_comma_space_s_length);
+  const f_string_static_t kt_remove_different_s = macro_f_string_static_t_initialize_1(KT_REMOVE_different_s, 0, KT_REMOVE_different_s_length);
   const f_string_static_t kt_remove_each_s = macro_f_string_static_t_initialize_1(KT_REMOVE_each_s, 0, KT_REMOVE_each_s_length);
   const f_string_static_t kt_remove_empty_s = macro_f_string_static_t_initialize_1(KT_REMOVE_empty_s, 0, KT_REMOVE_empty_s_length);
-  const f_string_static_t kt_remove_different_s = macro_f_string_static_t_initialize_1(KT_REMOVE_different_s, 0, KT_REMOVE_different_s_length);
   const f_string_static_t kt_remove_follow_s = macro_f_string_static_t_initialize_1(KT_REMOVE_follow_s, 0, KT_REMOVE_follow_s_length);
   const f_string_static_t kt_remove_force_s = macro_f_string_static_t_initialize_1(KT_REMOVE_force_s, 0, KT_REMOVE_force_s_length);
   const f_string_static_t kt_remove_group_s = macro_f_string_static_t_initialize_1(KT_REMOVE_group_s, 0, KT_REMOVE_group_s_length);
@@ -42,6 +44,7 @@ extern "C" {
   const f_string_static_t kt_remove_tree_s = macro_f_string_static_t_initialize_1(KT_REMOVE_tree_s, 0, KT_REMOVE_tree_s_length);
   const f_string_static_t kt_remove_yes_s = macro_f_string_static_t_initialize_1(KT_REMOVE_yes_s, 0, KT_REMOVE_yes_s_length);
   const f_string_static_t kt_remove_yesterday_s = macro_f_string_static_t_initialize_1(KT_REMOVE_yesterday_s, 0, KT_REMOVE_yesterday_s_length);
+  const f_string_static_t kt_remove_unknown_s = macro_f_string_static_t_initialize_1(KT_REMOVE_unknown_s, 0, KT_REMOVE_unknown_s_length);
   const f_string_static_t kt_remove_user_s = macro_f_string_static_t_initialize_1(KT_REMOVE_user_s, 0, KT_REMOVE_user_s_length);
 #endif // _di_kt_remove_s_
 
@@ -166,6 +169,9 @@ extern "C" {
 #endif // _di_kt_remove_parameter_s_
 
 #ifndef _di_kt_remove_print_reason_s_
+  const f_string_static_t kt_remove_print_reason_cannot_execute_s = macro_f_string_static_t_initialize_1(KT_REMOVE_print_reason_cannot_execute_s, 0, KT_REMOVE_print_reason_cannot_execute_s_length);
+  const f_string_static_t kt_remove_print_reason_cannot_read_s = macro_f_string_static_t_initialize_1(KT_REMOVE_print_reason_cannot_read_s, 0, KT_REMOVE_print_reason_cannot_read_s_length);
+  const f_string_static_t kt_remove_print_reason_cannot_write_s = macro_f_string_static_t_initialize_1(KT_REMOVE_print_reason_cannot_write_s, 0, KT_REMOVE_print_reason_cannot_write_s_length);
   const f_string_static_t kt_remove_print_reason_no_access_s = macro_f_string_static_t_initialize_1(KT_REMOVE_print_reason_no_access_s, 0, KT_REMOVE_print_reason_no_access_s_length);
   const f_string_static_t kt_remove_print_reason_not_found_s = macro_f_string_static_t_initialize_1(KT_REMOVE_print_reason_not_found_s, 0, KT_REMOVE_print_reason_not_found_s_length);
   const f_string_static_t kt_remove_print_reason_stat_fail_s = macro_f_string_static_t_initialize_1(KT_REMOVE_print_reason_stat_fail_s, 0, KT_REMOVE_print_reason_stat_fail_s_length);
index e13104f0fe084b99a330ddac60ff4a6a49b579d9..6690b6207f282e1cb149b2adf2073b30c30dd1a1 100644 (file)
@@ -69,9 +69,11 @@ extern "C" {
  * kt_remove_*_s: Arbitrary strings.
  */
 #ifndef _di_kt_remove_s_
+  #define KT_REMOVE_access_s      "access"
+  #define KT_REMOVE_comma_space_s ", "
+  #define KT_REMOVE_different_s   "different"
   #define KT_REMOVE_each_s        "each"
   #define KT_REMOVE_empty_s       "empty"
-  #define KT_REMOVE_different_s   "different"
   #define KT_REMOVE_follow_s      "follow"
   #define KT_REMOVE_force_s       "force"
   #define KT_REMOVE_group_s       "group"
@@ -98,11 +100,14 @@ extern "C" {
   #define KT_REMOVE_tree_s        "tree"
   #define KT_REMOVE_yes_s         "yes"
   #define KT_REMOVE_yesterday_s   "yesterday"
+  #define KT_REMOVE_unknown_s     "unknown"
   #define KT_REMOVE_user_s        "user"
 
+  #define KT_REMOVE_access_s_length      6
+  #define KT_REMOVE_comma_space_s_length 2
+  #define KT_REMOVE_different_s_length   9
   #define KT_REMOVE_each_s_length        4
   #define KT_REMOVE_empty_s_length       5
-  #define KT_REMOVE_different_s_length   9
   #define KT_REMOVE_follow_s_length      6
   #define KT_REMOVE_force_s_length       5
   #define KT_REMOVE_group_s_length       5
@@ -129,11 +134,14 @@ extern "C" {
   #define KT_REMOVE_tree_s_length        4
   #define KT_REMOVE_yes_s_length         3
   #define KT_REMOVE_yesterday_s_length   9
+  #define KT_REMOVE_unknown_s_length     7
   #define KT_REMOVE_user_s_length        4
 
+  extern const f_string_static_t kt_remove_access_s;
+  extern const f_string_static_t kt_remove_comma_space_s;
+  extern const f_string_static_t kt_remove_different_s;
   extern const f_string_static_t kt_remove_each_s;
   extern const f_string_static_t kt_remove_empty_s;
-  extern const f_string_static_t kt_remove_different_s;
   extern const f_string_static_t kt_remove_follow_s;
   extern const f_string_static_t kt_remove_force_s;
   extern const f_string_static_t kt_remove_group_s;
@@ -160,6 +168,7 @@ extern "C" {
   extern const f_string_static_t kt_remove_tree_s;
   extern const f_string_static_t kt_remove_yes_s;
   extern const f_string_static_t kt_remove_yesterday_s;
+  extern const f_string_static_t kt_remove_unknown_s;
   extern const f_string_static_t kt_remove_user_s;
 #endif // _di_kt_remove_s_
 
@@ -576,14 +585,23 @@ extern "C" {
  * Strings used printing the reason why a removal failed.
  */
 #ifndef _di_kt_remove_print_reason_s_
-  #define KT_REMOVE_print_reason_no_access_s "file be accessed"
-  #define KT_REMOVE_print_reason_not_found_s "file cannot be found"
-  #define KT_REMOVE_print_reason_stat_fail_s "cannot read file statistics"
-
-  #define KT_REMOVE_print_reason_no_access_s_length 16
-  #define KT_REMOVE_print_reason_not_found_s_length 20
-  #define KT_REMOVE_print_reason_stat_fail_s_length 27
-
+  #define KT_REMOVE_print_reason_cannot_execute_s "cannot execute"
+  #define KT_REMOVE_print_reason_cannot_read_s    "cannot read"
+  #define KT_REMOVE_print_reason_cannot_write_s   "cannot write"
+  #define KT_REMOVE_print_reason_no_access_s      "file be accessed"
+  #define KT_REMOVE_print_reason_not_found_s      "file cannot be found"
+  #define KT_REMOVE_print_reason_stat_fail_s      "cannot read file statistics"
+
+  #define KT_REMOVE_print_reason_cannot_execute_s_length 14
+  #define KT_REMOVE_print_reason_cannot_read_s_length    11
+  #define KT_REMOVE_print_reason_cannot_write_s_length   12
+  #define KT_REMOVE_print_reason_no_access_s_length      16
+  #define KT_REMOVE_print_reason_not_found_s_length      20
+  #define KT_REMOVE_print_reason_stat_fail_s_length      27
+
+  extern const f_string_static_t kt_remove_print_reason_cannot_execute_s;
+  extern const f_string_static_t kt_remove_print_reason_cannot_read_s;
+  extern const f_string_static_t kt_remove_print_reason_cannot_write_s;
   extern const f_string_static_t kt_remove_print_reason_no_access_s;
   extern const f_string_static_t kt_remove_print_reason_not_found_s;
   extern const f_string_static_t kt_remove_print_reason_stat_fail_s;
index a2f14de06d4fa7d15b603d2fe5b227f4bbdd6660..54f5d89e2d4729a0ba348e0af06f9e21dc64a007 100644 (file)
@@ -9,6 +9,8 @@ extern "C" {
 
     if (!cache) return;
 
+    f_memory_array_resize(0, sizeof(uint64_t), (void **) &cache->flags.array, &cache->flags.used, &cache->flags.size);
+
     f_memory_array_resize(0, sizeof(f_polls_t), (void **) &cache->polls.array, &cache->polls.used, &cache->polls.size);
 
     f_memory_array_resize(0, sizeof(f_char_t), (void **) &cache->buffer.string, &cache->buffer.used, &cache->buffer.size);
index 67d4a38a5fcfd0355a7ced2e57de57dadd5e9dcd..5bd0f6ee70f43f44c81be945fc3ca12cc7749222 100644 (file)
@@ -140,6 +140,7 @@ extern "C" {
 /**
  * The program cache.
  *
+ * flags: An array of operate flags for each path at some depth (for use during directory recursion).
  * polls: An array of poll structures.
  *
  * buffer: The generic buffer.
@@ -153,6 +154,8 @@ extern "C" {
  */
 #ifndef _di_kt_remove_cache_t_
   typedef struct {
+    f_uint64s_t flags;
+
     f_polls_t polls;
 
     f_string_dynamic_t buffer;
@@ -167,6 +170,7 @@ extern "C" {
 
   #define kt_remove_cache_t_initialize \
     { \
+      f_uint64s_t_initialize, \
       f_polls_t_initialize, \
       f_string_dynamic_t_initialize, \
       f_string_dynamic_t_initialize, \
index b66aa6741358d4f121cc42184e85efd80c2c1be0..5c9067f6dbed582d590f7f432d0fda47d28b6ba1 100644 (file)
@@ -4,77 +4,39 @@
 extern "C" {
 #endif
 
-#ifndef _di_kt_remove_operate_directory_
-  f_status_t kt_remove_operate_directory(kt_remove_main_t * const main, const f_string_static_t path, const uint32_t flag_operate) {
-
-    // The recurse.state.code flags represent the top-level directory being recursed on.
-    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;
-
-    main->cache.recurse.depth_max = main->setting.flag & kt_remove_main_flag_recurse_d ? kt_remove_depth_max_d : 0;
-    main->cache.recurse.flag = f_directory_recurse_do_flag_before_action_after_d;
-    main->cache.recurse.path.used = 0;
-    main->cache.recurse.path_top = &path;
-
-    main->cache.recurse.action = &kt_remove_operate_recurse_action;
-    main->cache.recurse.handle = &kt_remove_operate_recurse_handle;
-
-    fl_directory_do(path, &main->cache.recurse);
-    if (F_status_is_error(main->cache.recurse.state.status)) return main->cache.recurse.state.status;
-
-    // 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);
-
-      if (F_status_is_error(status)) {
-        kt_remove_print_error(&main->program.error, macro_kt_remove_f(f_memory_array_resize));
-
-        return status;
-      }
-    }
-
-    return (main->setting.flag & kt_remove_main_flag_simulate_d) ? F_no : F_yes;
-  }
-#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, const uint8_t recurse) {
+  f_status_t kt_remove_operate_file(kt_remove_main_t * const main, const f_string_static_t path, const uint8_t recurse, const uint64_t flag_operate) {
 
     if (!main) return F_status_set_error(F_parameter);
     if (!path.used) return F_data_not;
-    if (F_status_is_error(main->setting.state.status)) return F_no;
-
+    if (F_status_is_error(main->setting.state.status) || (flag_operate & kt_remove_flag_operate_processed_d)) return F_no;
     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, recurse);
-
-    if (F_status_is_error(main->setting.state.status)) return main->setting.state.status;
-    if (flag_operate & kt_remove_flag_operate_processed_d) return F_no;
+    f_status_t status = F_okay;
 
     if (flag_operate & kt_remove_flag_operate_missing_d) {
-      main->setting.state.status = kt_remove_operate_memory_save(main, path, flag_operate);
+      status = kt_remove_operate_memory_save(main, path, flag_operate);
 
-      if (F_status_is_error(main->setting.state.status)) {
-        kt_remove_print_error_file(&main->program.error, macro_kt_remove_f(kt_remove_operate_memory_save), path, f_file_operation_process_s, fll_error_file_type_path_e);
+      if (F_status_is_error(status)) {
+        kt_remove_print_error_file_status(&main->program.error, macro_kt_remove_f(kt_remove_operate_memory_save), path, f_file_operation_process_s, fll_error_file_type_path_e, status);
 
-        return main->setting.state.status;
+        return status;
       }
 
       if (!(main->setting.flag & kt_remove_main_flag_force_simulate_d)) {
-        main->setting.state.status = F_status_set_error(F_file_found_not);
+        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);
+        kt_remove_print_error_file_status(&main->program.error, macro_kt_remove_f(kt_remove_preprocess_file), path, f_file_operation_delete_s, fll_error_file_type_file_e, status);
 
-        return main->setting.state.status;
+        return status;
       }
     }
     else {
-      main->setting.state.status = kt_remove_operate_file_prompt(main, path, flag_operate);
-      if (F_status_is_error(main->setting.state.status) || main->setting.state.status == F_skip) return main->setting.state.status;
+      status = kt_remove_operate_file_prompt(main, path, flag_operate);
+      if (F_status_is_error(status) || status == F_skip) return status;
 
-      return (flag_operate & kt_remove_flag_operate_directory_d) && !(recurse & kt_remove_flag_recurse_normal_d)
-        ? kt_remove_operate_directory(main, path, flag_operate)
+      return (flag_operate & kt_remove_flag_operate_directory_d) && !(recurse & kt_remove_flag_recurse_active_d)
+        ? kt_remove_operate_recurse(main, path, flag_operate)
         : kt_remove_operate_remove(main, path, flag_operate);
     }
 
@@ -83,7 +45,7 @@ extern "C" {
 #endif // _di_kt_remove_operate_file_
 
 #ifndef _di_kt_remove_operate_file_parent_
-  void kt_remove_operate_file_parent(kt_remove_main_t * const main, const f_string_static_t path) {
+  void kt_remove_operate_file_parent(kt_remove_main_t * const main, const f_string_static_t path, const uint64_t flag_operate) {
 
     if (!main || macro_kt_remove_signal_check(&main->program, &main->setting.state)) return;
 
@@ -93,7 +55,6 @@ extern "C" {
       return;
     }
 
-    const uint32_t flag_operate = kt_remove_preprocess_file(main, path, kt_remove_flag_operate_parent_d, kt_remove_flag_recurse_none_d);
     if (F_status_is_error(main->setting.state.status) || (flag_operate & kt_remove_flag_operate_processed_d)) return;
 
     if (flag_operate & kt_remove_flag_operate_missing_d) {
@@ -211,21 +172,19 @@ extern "C" {
 #endif // _di_kt_remove_operate_file_prompt_
 
 #ifndef _di_kt_remove_operate_memory_check_
-  void kt_remove_operate_memory_check(kt_remove_main_t * const main, const f_string_static_t path, uint32_t * const flag_operate) {
+  f_status_t kt_remove_operate_memory_check(kt_remove_main_t * const main, const f_string_static_t path, uint64_t * const flag_operate) {
 
-    if (!main) return;
+    if (!main || !flag_operate) {
+      kt_remove_print_error_file(&main->program.error, macro_kt_remove_f(kt_remove_operate_memory_check), path, f_file_operation_process_s, fll_error_file_type_path_e);
 
-    if (!path.used) {
-      main->setting.state.status = F_data_not;
-
-      return;
+      return F_status_set_error(F_parameter);
     }
 
-    *flag_operate &= ~kt_remove_flag_operate_processed_d;
+    if (!path.used) return F_data_not;
 
-    main->setting.state.status = F_okay;
+    *flag_operate &= ~kt_remove_flag_operate_processed_d;
 
-    if (!main->cache.memory.used) return;
+    if (!main->cache.memory.used) return F_okay;
 
     f_range_t range = f_range_t_initialize;
     f_number_unsigned_t i = 0;
@@ -233,7 +192,7 @@ extern "C" {
     if (main->setting.flag & kt_remove_main_flag_recurse_d) {
       for (; i < main->cache.memory.used; ++i) {
 
-        if (macro_kt_remove_signal_check(&main->program, &main->setting.state)) return;
+        if (macro_kt_remove_signal_check(&main->program, &main->setting.state)) return F_status_set_error(F_interrupt);
         if (!main->cache.memory.array[i].used) continue;
 
         // The memory cache is nulless and top-most directories end in slashes.
@@ -272,7 +231,7 @@ extern "C" {
       // Only perform exact matches when not using recursion.
       for (; i < main->cache.memory.used; ++i) {
 
-        if (macro_kt_remove_signal_check(&main->program, &main->setting.state)) return;
+        if (macro_kt_remove_signal_check(&main->program, &main->setting.state)) return F_status_set_error(F_interrupt);
 
         if (f_compare_dynamic(main->cache.memory.array[i], path) == F_equal_to) {
           *flag_operate |= kt_remove_flag_operate_processed_d;
@@ -281,11 +240,13 @@ extern "C" {
         }
       } // for
     }
+
+    return F_okay;
   }
 #endif // _di_kt_remove_operate_memory_check_
 
 #ifndef _di_kt_remove_operate_memory_save_
-  f_status_t kt_remove_operate_memory_save(kt_remove_main_t * const main, const f_string_static_t path, const uint32_t flag_operate) {
+  f_status_t kt_remove_operate_memory_save(kt_remove_main_t * const main, const f_string_static_t path, const uint64_t flag_operate) {
 
     if (!main) return F_status_set_error(F_parameter);
     if (!path.used) return F_data_not;
@@ -334,22 +295,122 @@ extern "C" {
   }
 #endif // _di_kt_remove_operate_memory_save_
 
+#ifndef _di_kt_remove_operate_recurse_
+  f_status_t kt_remove_operate_recurse(kt_remove_main_t * const main, const f_string_static_t path, const uint64_t flag_operate) {
+
+    if (!main) {
+      kt_remove_print_error(&main->program.error, macro_kt_remove_f(kt_remove_operate_recurse));
+
+      return F_status_set_error(F_parameter);
+    }
+
+    main->cache.flags.used = 0;
+
+    {
+      const f_status_t status = f_memory_array_increase(kt_remove_allocation_small_d, sizeof(uint64_t), (void **) &main->cache.flags.array, &main->cache.flags.used, &main->cache.flags.size);
+
+      if (F_status_is_error(status)) {
+        kt_remove_print_error(&main->program.error, macro_kt_remove_f(f_memory_array_increase));
+
+        return status;
+      }
+    }
+
+    main->cache.flags.array[main->cache.flags.used++] = flag_operate;
+
+    // The recurse.state.code flags represent the top-level directory being recursed on.
+    main->cache.recurse.state.code = flag_operate;
+    main->cache.recurse.state.custom = (void *) main;
+    main->cache.recurse.state.interrupt = &kt_remove_signal_check_recurse;
+
+    main->cache.recurse.depth_max = main->setting.flag & kt_remove_main_flag_recurse_d ? kt_remove_depth_max_d : 0;
+    main->cache.recurse.flag = f_directory_recurse_do_flag_before_action_after_d;
+    main->cache.recurse.path.used = 0;
+    main->cache.recurse.path_top = &path;
+
+    main->cache.recurse.action = &kt_remove_operate_recurse_action;
+    main->cache.recurse.handle = &kt_remove_operate_recurse_handle;
+
+    fl_directory_do(path, &main->cache.recurse);
+
+    main->cache.flags.used = 0;
+
+    // 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);
+
+      if (F_status_is_error(status)) {
+        kt_remove_print_error(&main->program.error, macro_kt_remove_f(f_memory_array_resize));
+
+        return F_status_is_error(main->cache.recurse.state.status)
+          ? main->cache.recurse.state.status
+          : status;
+      }
+    }
+
+    if (main->cache.flags.used > kt_remove_allocation_large_d) {
+      const f_status_t status = f_memory_array_resize(kt_remove_allocation_normal_d, sizeof(uint64_t), (void **) &main->cache.flags.array, &main->cache.flags.used, &main->cache.flags.size);
+
+      if (F_status_is_error(status)) {
+        kt_remove_print_error(&main->program.error, macro_kt_remove_f(f_memory_array_resize));
+
+        return F_status_is_error(main->cache.recurse.state.status)
+          ? main->cache.recurse.state.status
+          : status;
+      }
+    }
+
+    if (F_status_is_error(main->cache.recurse.state.status)) return main->cache.recurse.state.status;
+
+    return (main->setting.flag & kt_remove_main_flag_simulate_d) ? F_no : F_yes;
+  }
+#endif // _di_kt_remove_operate_recurse_
+
 #ifndef _di_kt_remove_operate_recurse_action_
-  void kt_remove_operate_recurse_action(f_directory_recurse_do_t * const recurse, const f_string_static_t name, const uint32_t flag) {
+  void kt_remove_operate_recurse_action(f_directory_recurse_do_t * const recurse, const f_string_static_t name, const uint64_t flag) {
 
     if (!recurse || !recurse->state.custom || F_status_set_fine(recurse->state.status) == F_interrupt) return;
 
     kt_remove_main_t * const main = (kt_remove_main_t *) recurse->state.custom;
 
-    if (!(flag & f_directory_recurse_do_flag_action_d) || !kt_remove_operate_shall_remove(recurse->state.code) && !((main->setting.flag & kt_remove_main_flag_simulate_d) && !recurse->depth)) return;
+    if (flag & f_directory_recurse_do_flag_before_d) {
+      if (recurse->depth + 1 > main->cache.flags.size) {
+        recurse->state.status = f_memory_array_resize(recurse->depth + kt_remove_allocation_small_d, sizeof(uint64_t), (void **) &main->cache.flags.array, &main->cache.flags.used, &main->cache.flags.size);
+        if (F_status_is_error(recurse->state.status)) return;
+      }
+
+      // Depth 0 is already been pre-processed and the value is stored in recurse.state.code.
+      if (recurse->depth) {
+        recurse->state.status = kt_remove_preprocess_file(main, recurse->path, kt_remove_flag_recurse_active_d, &main->cache.flags.array[recurse->depth]);
+      }
+      else {
+        main->cache.flags.array[recurse->depth] = recurse->state.code;
+      }
+
+      if (F_status_is_error_not(recurse->state.status)) {
+        main->cache.flags.used = recurse->depth + 1;
+      }
 
-    recurse->state.status = kt_remove_operate_file(
-      main,
-      recurse->path,
-      recurse->depth
-        ? kt_remove_flag_recurse_normal_d
-        : kt_remove_flag_recurse_normal_parent_d
-    );
+      if (main->cache.flags.array[recurse->depth] & kt_remove_flag_operate_unable_rx_d) {
+        recurse->state.status = F_recurse_not;
+      }
+
+      return;
+    }
+
+    if (flag & f_directory_recurse_do_flag_after_d) {
+
+      // Reset the flags used after directory processing.
+      if (flag & f_directory_recurse_do_flag_directory_d) {
+        main->cache.flags.used = recurse->depth + 1;
+      }
+
+      return;
+    }
+
+    if (!(flag & f_directory_recurse_do_flag_action_d) || !kt_remove_operate_shall_remove(main->cache.flags.array[recurse->depth])) return;
+
+    recurse->state.status = kt_remove_operate_file(main, recurse->path, kt_remove_flag_recurse_active_d, main->cache.flags.array[recurse->depth]);
 
     if (F_status_is_error_not(recurse->state.status)) {
       recurse->state.status = F_okay;
@@ -358,7 +419,7 @@ extern "C" {
 #endif // _di_kt_remove_operate_recurse_action_
 
 #ifndef _di_kt_remove_operate_recurse_handle_
-  void kt_remove_operate_recurse_handle(f_directory_recurse_do_t * const recurse, const f_string_static_t name, const uint32_t flag) {
+  void kt_remove_operate_recurse_handle(f_directory_recurse_do_t * const recurse, const f_string_static_t name, const uint64_t flag) {
 
     if (!recurse || !recurse->state.custom || F_status_set_fine(recurse->state.status) == F_interrupt) return;
 
@@ -367,10 +428,10 @@ extern "C" {
     // Ignore empty paths.
     if (recurse->state.status == F_data_not) return;
 
-    if (flag & f_directory_recurse_do_flag_list_d && recurse->state.status == F_status_set_error(F_recurse)) {
+    if (flag & f_directory_recurse_do_flag_list_d && F_status_set_fine(recurse->state.status) == F_recurse) {
       recurse->state.status = F_status_set_error(F_directory_empty_not);
 
-      kt_remove_print_error_file_status(&main->program.error, macro_kt_remove_f(fl_directory_do), (!recurse->depth && (flag & f_directory_recurse_do_flag_after_d)) ? *recurse->path_top : recurse->path, f_file_operation_delete_s, fll_error_file_type_directory_e, recurse->state.status);
+      kt_remove_print_error_file_status(&main->program.error, macro_kt_remove_f(fl_directory_do), (!recurse->depth && (flag & f_directory_recurse_do_flag_after_d)) ? *recurse->path_top : recurse->path, f_file_operation_delete_s, fll_error_file_type_path_e, recurse->state.status);
 
       return;
     }
@@ -382,16 +443,26 @@ extern "C" {
       return;
     }
 
-    if (recurse->state.status == F_status_set_error(F_parameter) || flag == f_directory_recurse_do_flag_path_list_d) {
+    if (F_status_set_fine(recurse->state.status) == F_parameter || flag == f_directory_recurse_do_flag_path_list_d) {
       kt_remove_print_error_file_status(&main->program.error, macro_kt_remove_f(fl_directory_do), (!recurse->depth && (flag & f_directory_recurse_do_flag_after_d)) ? *recurse->path_top : recurse->path, f_file_operation_list_s, fll_error_file_type_directory_e, recurse->state.status);
 
       return;
     }
+
+    if (F_status_set_fine(recurse->state.status) == F_access_denied) {
+      if (flag == f_directory_recurse_do_flag_list_d) {
+        kt_remove_print_error_file_status(&main->program.error, macro_kt_remove_f(fl_directory_do), (!recurse->depth && (flag & f_directory_recurse_do_flag_action_d)) ? *recurse->path_top : recurse->path, f_file_operation_delete_s, fll_error_file_type_directory_e, recurse->state.status);
+      }
+
+      return;
+    }
+
+    kt_remove_print_error_file_status(&main->program.error, macro_kt_remove_f(fl_directory_do), (!recurse->depth && (flag & f_directory_recurse_do_flag_action_d)) ? *recurse->path_top : recurse->path, f_file_operation_delete_s, fll_error_file_type_path_e, recurse->state.status);
   }
 #endif // _di_kt_remove_operate_recurse_handle_
 
 #ifndef _di_kt_remove_operate_remove_
-  f_status_t kt_remove_operate_remove(kt_remove_main_t * const main, const f_string_static_t path, const uint32_t flag_operate) {
+  f_status_t kt_remove_operate_remove(kt_remove_main_t * const main, const f_string_static_t path, const uint64_t flag_operate) {
 
     if (!main) return F_status_set_error(F_parameter);
     if (flag_operate & kt_remove_flag_operate_processed_d) return F_no;
@@ -477,7 +548,7 @@ extern "C" {
 #endif // _di_kt_remove_operate_remove_
 
 #ifndef _di_kt_remove_operate_shall_remove_
-  f_status_t kt_remove_operate_shall_remove(const uint32_t flag) {
+  f_status_t kt_remove_operate_shall_remove(const uint64_t flag) {
 
     return (flag & kt_remove_flag_operate_remove_d) && !(flag & kt_remove_flag_operate_remove_not_fail_d);
   }
index 84b0e8920c191775bdb8076c9f8ec7535a96d6d7..fb7db05241d0766a011ec43a89c42dbc397741f8 100644 (file)
@@ -13,40 +13,6 @@ extern "C" {
 #endif
 
 /**
- * Perform actual file removal for directory files.
- *
- * @param main
- *   The main program and settings data.
- *
- *   Must not be NULL.
- *
- *   This does not directly 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_operate_*_e.
- *
- * @return
- *   F_yes on success and file remove.
- *   F_no on success and file not removed.
- *   F_data_not on success but path is an empty string.
- *
- *   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_memory_array_resize()
- *   Errors (with error bit) from: fl_directory_do()
- *   Errors (with error bit) from: kt_remove_operate_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);
-#endif // _di_kt_remove_operate_directory_
-
-/**
  * Operate on a single file.
  *
  * @param main
@@ -75,21 +41,21 @@ extern "C" {
  *   F_interrupt (with error bit) on interrupt.
  *   F_parameter (with error bit) on invalid parameter.
  *
- *   Success from: kt_remove_operate_directory()
+ *   Success from: kt_remove_operate_recurse()
  *   Success from: kt_remove_operate_remove()
  *
- *   Errors (with error bit) from: kt_remove_operate_directory().
+ *   Errors (with error bit) from: kt_remove_operate_recurse().
  *   Errors (with error bit) from: kt_remove_operate_memory_save().
  *   Errors (with error bit) from: kt_remove_operate_remove().
  *   Errors (with error bit) from: kt_remove_preprocess_file().
  *
- * @see kt_remove_operate_directory()
+ * @see kt_remove_operate_recurse()
  * @see kt_remove_operate_memory_save()
  * @see kt_remove_operate_remove()
  * @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, const uint8_t recurse);
+  extern f_status_t kt_remove_operate_file(kt_remove_main_t * const main, const f_string_static_t path, const uint8_t recurse, const uint64_t flag_operate);
 #endif // _di_kt_remove_operate_file_
 
 /**
@@ -115,13 +81,15 @@ 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 flag_operate
+ *   The operate file specific flags from kt_remove_flag_operate_*_e.
  *
  * @see kt_remove_operate_memory_save()
  * @see kt_remove_operate_remove()
  * @see kt_remove_preprocess_file()
  */
 #ifndef _di_kt_remove_operate_file_parent_
-  extern void kt_remove_operate_file_parent(kt_remove_main_t * const main, const f_string_static_t path);
+  extern void kt_remove_operate_file_parent(kt_remove_main_t * const main, const f_string_static_t path, const uint64_t flag_operate);
 #endif // _di_kt_remove_operate_file_parent_
 
 /**
@@ -165,9 +133,7 @@ extern "C" {
  *
  *   Must not be NULL.
  *
- *   This alters main.setting.state.status:
- *     F_okay on success.
- *     F_data_not on success but path is an empty string.
+ *   This does not alter main.setting.state.status.
  * @param path
  *   The path to the file to operate on.
  * @param flag_operate
@@ -177,10 +143,14 @@ extern "C" {
  *
  *   Must not be NULL.
  *
+ * @return
+ *     F_okay on success.
+ *     F_data_not on success but path is an empty string.
+ *
  * @see f_string_dynamic_append()
  */
 #ifndef _di_kt_remove_operate_memory_check_
-  extern void kt_remove_operate_memory_check(kt_remove_main_t * const main, const f_string_static_t path, uint32_t * const flag_operate);
+  extern f_status_t kt_remove_operate_memory_check(kt_remove_main_t * const main, const f_string_static_t path, uint64_t * const flag_operate);
 #endif // _di_kt_remove_operate_memory_check_
 
 /**
@@ -213,10 +183,45 @@ extern "C" {
  * @see f_string_dynamic_append_nulless()
  */
 #ifndef _di_kt_remove_operate_memory_save_
-  extern f_status_t kt_remove_operate_memory_save(kt_remove_main_t * const main, const f_string_static_t path, const uint32_t flag_operate);
+  extern f_status_t kt_remove_operate_memory_save(kt_remove_main_t * const main, const f_string_static_t path, const uint64_t flag_operate);
 #endif // _di_kt_remove_operate_memory_save_
 
 /**
+ * Perform recursion on a directory, removing that directory and its contents.
+ *
+ * @param main
+ *   The main program and settings data.
+ *
+ *   Must not be NULL.
+ *
+ *   This does not directly 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_operate_*_e.
+ *
+ * @return
+ *   F_yes on success and file remove.
+ *   F_no on success and file not removed.
+ *   F_data_not on success but path is an empty string.
+ *
+ *   F_no (with error bit) on failure and file is not to be removed or cannot be removed.
+ *   F_parameter (with error bit) on invalid parameter.
+ *   F_recurse (with error bit) on max recursion depth reached.
+ *
+ *   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_memory_array_resize()
+ * @see fl_directory_do()
+ * @see kt_remove_operate_remove()
+ */
+#ifndef _di_kt_remove_operate_recurse_
+  extern f_status_t kt_remove_operate_recurse(kt_remove_main_t * const main, const f_string_static_t path, const uint64_t flag_operate);
+#endif // _di_kt_remove_operate_recurse_
+
+/**
  * Perform directory recurse for a single file operation action.
  *
  * @param recurse
@@ -234,7 +239,7 @@ extern "C" {
  * @see fl_directory_do()
  */
 #ifndef _di_kt_remove_operate_recurse_action_
-  extern void kt_remove_operate_recurse_action(f_directory_recurse_do_t * const recurse, const f_string_static_t name, const uint32_t flag);
+  extern void kt_remove_operate_recurse_action(f_directory_recurse_do_t * const recurse, const f_string_static_t name, const uint64_t flag);
 #endif // _di_kt_remove_operate_recurse_action_
 
 /**
@@ -254,7 +259,7 @@ extern "C" {
  * @see fl_directory_do()
  */
 #ifndef _di_kt_remove_operate_recurse_handle_
-  extern void kt_remove_operate_recurse_handle(f_directory_recurse_do_t * const recurse, const f_string_static_t name, const uint32_t flag);
+  extern void kt_remove_operate_recurse_handle(f_directory_recurse_do_t * const recurse, const f_string_static_t name, const uint64_t flag);
 #endif // _di_kt_remove_operate_recurse_handle_
 
 /**
@@ -288,7 +293,7 @@ extern "C" {
  * @see f_file_remove()
  */
 #ifndef _di_kt_remove_operate_remove_
-  extern f_status_t kt_remove_operate_remove(kt_remove_main_t * const main, const f_string_static_t path, const uint32_t flag_operate);
+  extern f_status_t kt_remove_operate_remove(kt_remove_main_t * const main, const f_string_static_t path, const uint64_t flag_operate);
 #endif // _di_kt_remove_operate_remove_
 
 /**
@@ -302,7 +307,7 @@ extern "C" {
  *   F_false otherwise.
  */
 #ifndef _di_kt_remove_operate_shall_remove_
-  extern f_status_t kt_remove_operate_shall_remove(const uint32_t flag);
+  extern f_status_t kt_remove_operate_shall_remove(const uint64_t flag);
 #endif // _di_kt_remove_operate_shall_remove_
 
 #ifdef __cplusplus
index 932300f58db5c4d09c306f56efbf68ca8a875f43..d5a8dd6a8229da801bbb13a17f05960513213968 100644 (file)
@@ -5,28 +5,27 @@ 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, const uint8_t recurse) {
+  f_status_t kt_remove_preprocess_file(kt_remove_main_t * const main, const f_string_static_t path, const uint8_t recurse, uint64_t * const flag_operate) {
 
-    if (!main) return 0;
+    if (!main || !flag_operate) {
+      kt_remove_print_error_file(&main->program.error, macro_kt_remove_f(kt_remove_preprocess_file), path, f_file_operation_process_s, fll_error_file_type_path_e);
 
-    if (!path.used) {
-      main->setting.state.status = F_data_not;
-
-      return 0;
+      return F_status_set_error(F_parameter);
     }
 
-    if (macro_kt_remove_signal_check(&main->program, &main->setting.state)) return 0;
+    if (macro_kt_remove_signal_check(&main->program, &main->setting.state)) return F_status_set_error(F_interrupt);
+    if (!path.used) return F_data_not;
 
-    uint32_t flag_out = (main->setting.flag & kt_remove_main_flag_option_type_used_d) ? 0 : kt_remove_flag_operate_remove_d;
+    *flag_operate = (main->setting.flag & kt_remove_main_flag_option_type_used_d) ? 0 : kt_remove_flag_operate_remove_d;
 
-    kt_remove_operate_memory_check(main, path, &flag_out);
+    f_status_t status = kt_remove_operate_memory_check(main, path, flag_operate);
 
-    if (F_status_is_error(main->setting.state.status) || (flag_out & kt_remove_flag_operate_processed_d)) {
-      kt_remove_print_simulate_operate_file(&main->program.output, flag_out, path);
+    if (F_status_is_error(status) || ((*flag_operate) & kt_remove_flag_operate_processed_d)) {
+      kt_remove_print_simulate_operate_file(&main->program.output, *flag_operate, path);
 
-      kt_remove_print_simulate_operate_boolean(&main->program.output, flag_out, kt_remove_skip_s, F_true);
+      kt_remove_print_simulate_operate_boolean(&main->program.output, *flag_operate, kt_remove_skip_s, F_true);
 
-      return flag_out;
+      return F_skip;
     }
 
     f_number_unsigned_t i = 0;
@@ -36,141 +35,150 @@ extern "C" {
     memset(&statistics, 0, sizeof(struct stat));
 
     {
-      const f_status_t exists = main->setting.state.status = f_file_exists(path, main->setting.flag & kt_remove_main_flag_follow_d);
+      const f_status_t exists = status = f_file_exists(path, main->setting.flag & kt_remove_main_flag_follow_d);
 
       if (exists == F_true) {
-        main->setting.state.status = f_file_is(path, F_file_type_link_d, F_false);
+        status = f_file_is(path, F_file_type_link_d, F_false);
+
+        if (F_status_is_error(status)) {
+          *flag_operate |= kt_remove_flag_operate_remove_fail_d;
 
-        if (F_status_is_error(main->setting.state.status)) {
-          kt_remove_print_simulate_operate_file(&main->program.output, flag_out, path);
+          kt_remove_print_simulate_operate_file(&main->program.output, *flag_operate, path);
 
           remove_print_warning_file_reason(&main->program.warning, path, kt_remove_print_reason_stat_fail_s);
 
-          return 0;
+          return status;
         }
 
-        if (main->setting.state.status == F_true) {
-          flag_out |= kt_remove_flag_operate_link_d;
+        if (status == F_true) {
+          *flag_operate |= kt_remove_flag_operate_link_d;
         }
       }
       else if (exists == F_false || F_status_is_error(exists)) {
-        kt_remove_print_simulate_operate_file(&main->program.output, flag_out, path);
+        *flag_operate |= F_status_is_error(exists)
+          ? kt_remove_flag_operate_remove_not_fail_d
+          : kt_remove_flag_operate_remove_not_d;
 
-        kt_remove_print_simulate_operate_file_exists(&main->program.output, flag_out, path, exists);
+        kt_remove_print_simulate_operate_file(&main->program.output, *flag_operate, path);
+        kt_remove_print_simulate_operate_file_exists(&main->program.output, *flag_operate, path, exists);
 
         if (exists == F_false) {
-          kt_remove_print_simulate_operate_boolean(&main->program.output, flag_out, kt_remove_ignore_s, main->setting.flag & kt_remove_main_flag_force_d);
+          kt_remove_print_simulate_operate_boolean(&main->program.output, *flag_operate, kt_remove_ignore_s, main->setting.flag & kt_remove_main_flag_force_d);
 
-          return kt_remove_flag_operate_missing_d;
+          if ((main->setting.flag & kt_remove_main_flag_simulate_d) || (main->setting.flag & kt_remove_main_flag_force_d)) {
+            return kt_remove_flag_operate_missing_d;
+          }
         }
 
-        remove_print_warning_file_reason(&main->program.warning, path, kt_remove_print_reason_no_access_s);
+        kt_remove_print_error_file_status(&main->program.error, macro_kt_remove_f(f_file_exists), path, f_file_operation_delete_s, fll_error_file_type_path_e, F_status_set_error(F_file_found_not));
+
+        main->setting.flag |= kt_remove_main_flag_return_fail_d;
 
-        return 0;
+        return F_no;
       }
 
-      if (macro_kt_remove_signal_check(&main->program, &main->setting.state)) return 0;
+      if (macro_kt_remove_signal_check(&main->program, &main->setting.state)) return F_status_set_error(F_interrupt);
 
       if (main->setting.flag & kt_remove_main_flag_follow_d) {
-        flag_out |= kt_remove_flag_operate_follow_d;
+        *flag_operate |= kt_remove_flag_operate_follow_d;
       }
 
-      main->setting.state.status = f_file_stat(path, main->setting.flag & kt_remove_main_flag_follow_d, &statistics);
+      status = f_file_stat(path, main->setting.flag & kt_remove_main_flag_follow_d, &statistics);
 
-      if (F_status_is_error(main->setting.state.status)) {
-        kt_remove_print_simulate_operate_file(&main->program.output, flag_out, path);
+      if (F_status_is_error(status)) {
+        *flag_operate |= kt_remove_flag_operate_remove_fail_d;
 
-        kt_remove_print_simulate_operate_file_exists(&main->program.output, flag_out, path, F_false);
+        kt_remove_print_simulate_operate_file(&main->program.output, *flag_operate, path);
+
+        kt_remove_print_simulate_operate_file_exists(&main->program.output, *flag_operate, path, F_false);
 
         remove_print_warning_file_reason(&main->program.warning, path, kt_remove_print_reason_stat_fail_s);
 
-        return flag_out;
+        return status;
       }
 
       if (macro_f_file_type_is_directory(statistics.st_mode)) {
-        flag_out |= kt_remove_flag_operate_directory_d;
-      }
-
-      if ((recurse & kt_remove_flag_recurse_top_d) && (flag_out & kt_remove_flag_operate_directory_d)) {
-        flag_out |= kt_remove_flag_operate_top_simulate_not_d;
+        *flag_operate |= kt_remove_flag_operate_directory_d;
       }
 
-      kt_remove_print_simulate_operate_file(&main->program.output, flag_out, path);
+      kt_remove_print_simulate_operate_file(&main->program.output, *flag_operate, path);
 
-      kt_remove_print_simulate_operate_file_exists(&main->program.output, flag_out, path, exists);
+      kt_remove_print_simulate_operate_file_exists(&main->program.output, *flag_operate, path, exists);
     }
 
     if (!(main->setting.flag & kt_remove_main_flag_root_d)) {
       if (f_compare_dynamic(f_string_ascii_slash_forward_s, path) == F_equal_to) {
         kt_remove_print_error_file_is_a(&main->program.error, path, kt_remove_not_allowed_s, 0);
 
-        flag_out |= kt_remove_flag_operate_remove_not_d;
+        *flag_operate |= kt_remove_flag_operate_remove_not_d;
       }
     }
 
-    kt_remove_preprocess_file_type(main, kt_remove_flag_simulate_is_a_d, 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);
+    status = kt_remove_preprocess_file_access(main, path, flag_operate);
+
+    if (F_status_is_error(status)) {
+      *flag_operate |= kt_remove_flag_operate_remove_fail_d;
 
-    kt_remove_preprocess_file_type(main, kt_remove_flag_simulate_is_a_d, 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);
+      return status;
+    }
 
-    kt_remove_preprocess_file_type(main, kt_remove_flag_simulate_is_a_d, 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);
+    kt_remove_preprocess_file_type(main, kt_remove_flag_simulate_is_a_d, 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_operate);
 
-    kt_remove_preprocess_file_type(main, kt_remove_flag_simulate_is_a_d, 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, 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_operate);
 
-    kt_remove_preprocess_file_type(main, kt_remove_flag_simulate_is_a_d, 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_d, 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_operate);
 
-    kt_remove_preprocess_file_type(main, kt_remove_flag_simulate_is_a_file_d, 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, 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_operate);
 
-    kt_remove_preprocess_file_type(main, kt_remove_flag_simulate_is_a_d, 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, kt_remove_flag_simulate_is_a_d, 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_operate);
 
-    kt_remove_preprocess_file_type(main, kt_remove_flag_simulate_none_d, 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);
+    kt_remove_preprocess_file_type(main, kt_remove_flag_simulate_is_a_file_d, 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_operate);
 
-    if (!(main->setting.flag & kt_remove_main_flag_simulate_d) && (flag_out & kt_remove_flag_operate_remove_fail_d)) {
-      main->setting.state.status = F_status_set_error(F_no);
+    kt_remove_preprocess_file_type(main, kt_remove_flag_simulate_is_a_d, 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_operate);
 
-      return flag_out;
-    }
+    kt_remove_preprocess_file_type(main, kt_remove_flag_simulate_none_d, 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_operate);
 
     if (main->setting.flag & kt_remove_main_flag_user_d) {
       for (i = 0; i < main->setting.users.used; ++i) {
 
-        if (macro_kt_remove_signal_check(&main->program, &main->setting.state)) return flag_out;
+        if (macro_kt_remove_signal_check(&main->program, &main->setting.state)) return F_status_set_error(F_interrupt);
         if (statistics.st_uid == (uid_t) main->setting.users.array[i]) break;
       } // for
 
-      kt_remove_print_simulate_operate_id(&main->program.output, flag_out, (f_number_unsigned_t) statistics.st_uid, F_true);
+      kt_remove_print_simulate_operate_id(&main->program.output, *flag_operate, (f_number_unsigned_t) statistics.st_uid, F_true);
 
       if (i < main->setting.users.used) {
-        flag_out |= kt_remove_flag_operate_remove_d;
+        *flag_operate |= kt_remove_flag_operate_remove_d;
       }
     }
 
     if (main->setting.flag & kt_remove_main_flag_same_d) {
-      kt_remove_print_simulate_operate_boolean(&main->program.output, flag_out, kt_remove_same_s, statistics.st_uid == geteuid());
+      kt_remove_print_simulate_operate_boolean(&main->program.output, *flag_operate, kt_remove_same_s, statistics.st_uid == geteuid());
 
       if (statistics.st_uid == geteuid()) {
-        flag_out |= kt_remove_flag_operate_remove_d;
+        *flag_operate |= kt_remove_flag_operate_remove_d;
       }
     }
 
     if (main->setting.flag & kt_remove_main_flag_different_d) {
-      kt_remove_print_simulate_operate_boolean(&main->program.output, flag_out, kt_remove_different_s, statistics.st_uid != geteuid());
+      kt_remove_print_simulate_operate_boolean(&main->program.output, *flag_operate, kt_remove_different_s, statistics.st_uid != geteuid());
 
       if (statistics.st_uid != geteuid()) {
-        flag_out |= kt_remove_flag_operate_remove_d;
+        *flag_operate |= kt_remove_flag_operate_remove_d;
       }
     }
 
     if (main->setting.flag & kt_remove_main_flag_group_d) {
       for (i = 0; i < main->setting.groups.used; ++i) {
 
-        if (macro_kt_remove_signal_check(&main->program, &main->setting.state)) return flag_out;
+        if (macro_kt_remove_signal_check(&main->program, &main->setting.state)) return F_status_set_error(F_interrupt);
         if (statistics.st_gid == (gid_t) main->setting.groups.array[i]) break;
       } // for
 
-      kt_remove_print_simulate_operate_id(&main->program.output, flag_out, (f_number_unsigned_t) statistics.st_gid, F_false);
+      kt_remove_print_simulate_operate_id(&main->program.output, *flag_operate, (f_number_unsigned_t) statistics.st_gid, F_false);
 
       if (i < main->setting.groups.used) {
-        flag_out |= kt_remove_flag_operate_remove_d;
+        *flag_operate |= kt_remove_flag_operate_remove_d;
       }
     }
 
@@ -191,11 +199,11 @@ extern "C" {
         kt_remove_flag_mode_not_d,
       };
 
-      kt_remove_print_simulate_operate_mode(&main->program.output, flag_out, (f_number_unsigned_t) mode, f_string_empty_s);
+      kt_remove_print_simulate_operate_mode(&main->program.output, *flag_operate, (f_number_unsigned_t) mode, f_string_empty_s);
 
       for (i = 0; i < main->setting.modes.used; ++i) {
 
-        if (macro_kt_remove_signal_check(&main->program, &main->setting.state)) return flag_out;
+        if (macro_kt_remove_signal_check(&main->program, &main->setting.state)) return F_status_set_error(F_interrupt);
 
         if (main->setting.modes.array[i].type == kt_remove_flag_mode_different_d) {
           if (main->setting.modes.array[i].mode ^ mode) break;
@@ -215,102 +223,126 @@ 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, flag_out, (f_number_unsigned_t) main->setting.modes.array[i].mode, modes[j]);
+            kt_remove_print_simulate_operate_mode(&main->program.output, *flag_operate, (f_number_unsigned_t) main->setting.modes.array[i].mode, modes[j]);
 
             break;
           }
         } // for
 
-        flag_out |= kt_remove_flag_operate_remove_d;
+        *flag_operate |= kt_remove_flag_operate_remove_d;
       }
     }
 
     if (main->setting.flag & kt_remove_main_flag_accessed_changed_updated_d) {
-      kt_remove_preprocess_file_dates(main, path, flag_operate, statistics);
-      if (F_status_is_error(main->setting.state.status)) return flag_out;
+      status = kt_remove_preprocess_file_dates(main, path, *flag_operate, statistics);
+
+      if (F_status_is_error(status)) {
+        *flag_operate |= kt_remove_flag_operate_remove_fail_d;
+
+        return status;
+      }
 
-      if (main->setting.state.status == F_yes) {
-        flag_out |= kt_remove_flag_operate_remove_d;
+      if (status == F_yes) {
+        *flag_operate |= kt_remove_flag_operate_remove_d;
       }
     }
 
-    if (flag_out & kt_remove_flag_operate_directory_d) {
-      main->setting.state.status = f_directory_empty(path);
-      if (F_status_is_error(main->setting.state.status)) return flag_out;
+    if ((*flag_operate) & kt_remove_flag_operate_directory_d) {
+      if ((*flag_operate) & kt_remove_flag_operate_unable_read_d) {
+        *flag_operate &= ~kt_remove_flag_operate_empty_d;
+
+        kt_remove_print_simulate_operate_unknown(&main->program.output, *flag_operate, kt_remove_empty_s);
+      }
+      else {
+        status = f_directory_empty(path);
+
+        if (F_status_is_error(status)) {
+          *flag_operate |= kt_remove_flag_operate_remove_fail_d;
 
-      if (main->setting.state.status == F_true || main->setting.state.status == F_false) {
-        if (main->setting.state.status == F_true) {
-          flag_out |= kt_remove_flag_operate_empty_d;
-        } else {
-          flag_out &= ~kt_remove_flag_operate_empty_d;
+          kt_remove_print_error_file_status(&main->program.error, macro_kt_remove_f(f_directory_empty), path, f_file_operation_verify_s, fll_error_file_type_directory_e, status);
+
+          return status;
         }
 
-        kt_remove_print_simulate_operate_boolean(&main->program.output, flag_out, kt_remove_empty_s, main->setting.state.status);
+        if (status == F_true || status == F_false) {
+          if (status == F_true) {
+            *flag_operate |= kt_remove_flag_operate_empty_d;
+          } else {
+            *flag_operate &= ~kt_remove_flag_operate_empty_d;
+          }
+
+          kt_remove_print_simulate_operate_boolean(&main->program.output, *flag_operate, kt_remove_empty_s, status);
 
-        if (!(flag_out & kt_remove_flag_operate_remove_not_d)) {
-          if (main->setting.flag & kt_remove_main_flag_empty_all_d) {
-            if (flag_out & kt_remove_flag_operate_empty_d) {
-              if (main->setting.flag & kt_remove_main_flag_empty_not_fail_d) {
-                kt_remove_print_error_file_is_a(&main->program.error, path, kt_remove_empty_s, 0);
+          if (!((*flag_operate) & kt_remove_flag_operate_remove_not_d)) {
+            if (main->setting.flag & kt_remove_main_flag_empty_all_d) {
+              if ((*flag_operate) & kt_remove_flag_operate_empty_d) {
+                if (main->setting.flag & kt_remove_main_flag_empty_not_fail_d) {
+                  kt_remove_print_error_file_is_a(&main->program.error, path, kt_remove_empty_s, 0);
 
-                flag_out |= kt_remove_flag_operate_remove_fail_d;
+                  *flag_operate |= kt_remove_flag_operate_remove_fail_d;
+                }
+                else if (main->setting.flag & kt_remove_main_flag_empty_not_d) {
+                  *flag_operate |= kt_remove_flag_operate_remove_not_d;
+                }
               }
-              else if (main->setting.flag & kt_remove_main_flag_empty_not_d) {
-                flag_out |= kt_remove_flag_operate_remove_not_d;
+              else {
+                if (main->setting.flag & kt_remove_main_flag_empty_only_fail_d) {
+                  kt_remove_print_error_file_is_a(&main->program.error, path, kt_remove_not_empty_s, 0);
+
+                  *flag_operate |= kt_remove_flag_operate_remove_fail_d;
+                }
+                else if (main->setting.flag & kt_remove_main_flag_empty_only_d || !(main->setting.flag & (kt_remove_main_flag_empty_not_d | kt_remove_main_flag_recurse_d))) {
+                  *flag_operate |= kt_remove_flag_operate_remove_not_d;
+                }
               }
             }
-            else {
-              if (main->setting.flag & kt_remove_main_flag_empty_only_fail_d) {
+            else if (!((*flag_operate) & kt_remove_flag_operate_empty_d)) {
+              if (!(main->setting.flag & kt_remove_main_flag_recurse_d)) {
                 kt_remove_print_error_file_is_a(&main->program.error, path, kt_remove_not_empty_s, 0);
 
-                flag_out |= kt_remove_flag_operate_remove_fail_d;
-              }
-              else if (main->setting.flag & kt_remove_main_flag_empty_only_d || !(main->setting.flag & (kt_remove_main_flag_empty_not_d | kt_remove_main_flag_recurse_d))) {
-                flag_out |= kt_remove_flag_operate_remove_not_d;
+                *flag_operate |= kt_remove_flag_operate_remove_fail_d;
               }
             }
           }
-          else if (!(flag_out & kt_remove_flag_operate_empty_d)) {
-            if (!(main->setting.flag & kt_remove_main_flag_recurse_d)) {
-              kt_remove_print_error_file_is_a(&main->program.error, path, kt_remove_not_empty_s, 0);
-
-              flag_out |= kt_remove_flag_operate_remove_fail_d;
-            }
-          }
         }
       }
     }
 
-    if (flag_out & kt_remove_flag_operate_directory_d) {
-      kt_remove_print_simulate_operate_boolean(&main->program.output, flag_out, kt_remove_recurse_s, (main->setting.flag & kt_remove_main_flag_recurse_d) && !(flag_operate & kt_remove_flag_operate_parent_d));
+    if ((*flag_operate) & kt_remove_flag_operate_directory_d) {
+      kt_remove_print_simulate_operate_boolean(
+        &main->program.output,
+        *flag_operate,
+        kt_remove_recurse_s,
+        (main->setting.flag & kt_remove_main_flag_recurse_d) && !((*flag_operate) & kt_remove_flag_operate_parent_d) && !((*flag_operate) & kt_remove_flag_operate_unable_rx_d)
+      );
     }
 
     if (main->setting.flag & kt_remove_main_flag_tree_d) {
-      kt_remove_print_simulate_operate_boolean(&main->program.output, flag_out, kt_remove_parent_s, flag_operate & kt_remove_flag_operate_parent_d);
+      kt_remove_print_simulate_operate_boolean(&main->program.output, *flag_operate, kt_remove_parent_s, (*flag_operate) & kt_remove_flag_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, flag_out, kt_remove_prompt_s, main->setting.flag & kt_remove_main_flag_prompt_each_d);
+        kt_remove_print_simulate_operate_boolean(&main->program.output, *flag_operate, 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, flag_out, kt_remove_prompt_s, (main->setting.flag & kt_remove_main_flag_follow_d) && (flag_out & kt_remove_flag_operate_link_d));
+        kt_remove_print_simulate_operate_boolean(&main->program.output, *flag_operate, kt_remove_prompt_s, (main->setting.flag & kt_remove_main_flag_follow_d) && ((*flag_operate) & kt_remove_flag_operate_link_d));
       }
       else if (main->setting.flag & kt_remove_main_flag_prompt_once_d) {
-        kt_remove_print_simulate_operate_boolean(&main->program.output, flag_out, kt_remove_prompt_s, !(main->setting.prompt));
+        kt_remove_print_simulate_operate_boolean(&main->program.output, *flag_operate, kt_remove_prompt_s, !(main->setting.prompt));
       }
     }
 
-    kt_remove_print_simulate_operate_boolean(&main->program.output, flag_out, kt_remove_remove_s, kt_remove_operate_shall_remove(flag_out));
+    kt_remove_print_simulate_operate_boolean(&main->program.output, *flag_operate, kt_remove_remove_s, kt_remove_operate_shall_remove(*flag_operate));
 
     // Only apply tree operations on non-child paths when the tree flag is set.
-    if ((main->setting.flag & kt_remove_main_flag_tree_d) && !(recurse & kt_remove_flag_recurse_normal_d)) {
+    if ((main->setting.flag & kt_remove_main_flag_tree_d) && !(recurse & kt_remove_flag_recurse_active_d)) {
       f_range_t range = macro_f_range_t_initialize_2(path.used);
 
       if (range.stop > range.start) {
-        main->setting.state.status = f_string_dynamic_seek_to_back(path, f_string_ascii_slash_forward_s.string[0], &range);
+        status = f_string_dynamic_seek_to_back(path, f_string_ascii_slash_forward_s.string[0], &range);
 
-        if (F_status_is_error_not(main->setting.state.status) && F_status_set_fine(main->setting.state.status) == F_okay && range.stop > range.start) {
+        if (F_status_is_error_not(status) && F_status_set_fine(status) == F_okay && range.stop > range.start) {
           --range.stop;
 
           for (i = 0; i < main->cache.tree.used; ++i) {
@@ -318,49 +350,117 @@ extern "C" {
           } // for
 
           if (i == main->cache.tree.used) {
-            main->setting.state.status = f_memory_array_increase(kt_remove_allocation_small_d, sizeof(f_string_dynamic_t), (void **) &main->cache.tree.array, &main->cache.tree.used, &main->cache.tree.size);
+            status = f_memory_array_increase(kt_remove_allocation_small_d, sizeof(f_string_dynamic_t), (void **) &main->cache.tree.array, &main->cache.tree.used, &main->cache.tree.size);
+
+            if (F_status_is_error(status)) {
+              *flag_operate |= kt_remove_flag_operate_remove_fail_d;
 
-            if (F_status_is_error(main->setting.state.status)) {
-              kt_remove_print_error(&main->program.error, macro_kt_remove_f(f_memory_array_increase));
+              kt_remove_print_error_file_status(&main->program.error, macro_kt_remove_f(f_memory_array_increase), path, f_file_operation_process_s, fll_error_file_type_path_e, status);
 
-              return flag_out;
+              return status;
             }
 
             main->cache.tree.array[main->cache.tree.used].used = 0;
 
-            main->setting.state.status = f_string_dynamic_partial_append(path, range, &main->cache.tree.array[main->cache.tree.used]);
+            status = f_string_dynamic_partial_append(path, range, &main->cache.tree.array[main->cache.tree.used]);
 
-            if (F_status_is_error(main->setting.state.status)) {
-              kt_remove_print_error(&main->program.error, macro_kt_remove_f(f_string_dynamic_partial_append));
+            if (F_status_is_error(status)) {
+              *flag_operate |= kt_remove_flag_operate_remove_fail_d;
 
-              return flag_out;
+              kt_remove_print_error_file_status(&main->program.error, macro_kt_remove_f(f_string_dynamic_partial_append), path, f_file_operation_process_s, fll_error_file_type_path_e, status);
+
+              return status;
             }
 
             ++main->cache.tree.used;
           }
         }
-        else if (F_status_is_error(main->setting.state.status)) {
-          kt_remove_print_error_file(&main->program.error, macro_kt_remove_f(f_string_dynamic_seek_to_back), path, f_file_operation_process_s, fll_error_file_type_path_e);
+        else if (F_status_is_error(status)) {
+          *flag_operate |= kt_remove_flag_operate_remove_fail_d;
+
+          kt_remove_print_error_file_status(&main->program.error, macro_kt_remove_f(f_string_dynamic_seek_to_back), path, f_file_operation_process_s, fll_error_file_type_path_e, status);
 
-          return flag_out;
+          return status;
         }
       }
     }
 
-    if (F_status_is_error_not(main->setting.state.status)) {
-      main->setting.state.status = !(main->setting.flag & kt_remove_main_flag_simulate_d) && (flag_out & kt_remove_flag_operate_remove_fail_d)
+    if (!(main->setting.flag & kt_remove_main_flag_simulate_d) && ((*flag_operate) & kt_remove_flag_operate_remove_fail_d)) {
+      main->setting.flag |= kt_remove_main_flag_return_fail_d;
+
+      return F_no;
+    }
+
+    if (F_status_is_error_not(status)) {
+      status = !(main->setting.flag & kt_remove_main_flag_simulate_d) && ((*flag_operate) & kt_remove_flag_operate_remove_fail_d)
         ? F_status_set_error(F_no)
         : F_okay;
     }
 
-    return flag_out;
+    return status;
   }
 #endif // _di_kt_remove_preprocess_file_
 
+#ifndef _di_kt_remove_preprocess_file_access_
+  f_status_t kt_remove_preprocess_file_access(kt_remove_main_t * const main, const f_string_static_t path, uint64_t * const flag_operate) {
+
+    if (!main || !flag_operate) {
+      kt_remove_print_error_file_status(&main->program.error, macro_kt_remove_f(kt_remove_preprocess_file_access), path, f_file_operation_process_s, fll_error_file_type_path_e, F_status_set_error(F_parameter));
+
+      return F_status_set_error(F_parameter);
+    }
+
+    if (!path.used) return F_data_not;
+
+    f_status_t status = f_file_access(path, F_file_access_mode_read_d);
+
+    if (F_status_is_error_not(status)) {
+      if (status == F_false) {
+        *flag_operate |= kt_remove_flag_operate_unable_read_d;
+      }
+
+      status = f_file_access(path, F_file_access_mode_write_d);
+    }
+
+    if (F_status_is_error_not(status)) {
+      if (status == F_false) {
+        *flag_operate |= kt_remove_flag_operate_unable_write_d;
+      }
+
+      status = f_file_access(path, F_file_access_mode_execute_d);
+    }
+
+    if (F_status_is_error_not(status)) {
+      if (status == F_false) {
+        *flag_operate |= kt_remove_flag_operate_unable_execute_d;
+      }
+
+      if ((*flag_operate) & kt_remove_flag_operate_unable_rwx_d) {
+        kt_remove_print_simulate_operate_file_access(&main->program.output, *flag_operate, path);
+      }
+
+      status = F_okay;
+    }
+    else {
+      status = F_status_set_error(F_parameter);
+
+      kt_remove_print_error_file(&main->program.error, macro_kt_remove_f(f_file_access), path, f_file_operation_access_s, fll_error_file_type_path_e);
+    }
+
+    return status;
+  }
+#endif // _di_kt_remove_preprocess_file_access_
+
 #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) {
+  f_status_t kt_remove_preprocess_file_dates(kt_remove_main_t * const main, const f_string_static_t path, const uint64_t flag_operate, const struct stat statistics) {
 
-    if (!main) return;
+    if (!main) {
+      kt_remove_print_error_file_status(&main->program.error, macro_kt_remove_f(kt_remove_preprocess_file_dates), path, f_file_operation_process_s, fll_error_file_type_path_e, F_status_set_error(F_parameter));
+
+      return F_status_set_error(F_parameter);
+    }
+
+    if (!path.used) return F_data_not;
 
     uint8_t i = 0;
     f_number_unsigned_t j = 0;
@@ -407,7 +507,7 @@ extern "C" {
 
       for (j = 0; j < dates[i]->used; ++j) {
 
-        if (macro_kt_remove_signal_check(&main->program, &main->setting.state)) return;
+        if (macro_kt_remove_signal_check(&main->program, &main->setting.state)) return F_status_set_error(F_interrupt);
 
         match_nanosecond = times[i].tv_nsec;
         match_second = times[i].tv_sec % kt_remove_time_seconds_in_year_d;
@@ -611,12 +711,12 @@ extern "C" {
       } // for
     } // for
 
-    main->setting.state.status = result ? F_yes : F_no;
+    return result ? F_yes : F_no;
   }
 #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 uint8_t simulate, const f_string_static_t path, const uint8_t is, f_string_static_t name, const uint64_t type, const uint64_t ignore, 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 uint8_t is, f_string_static_t name, const uint64_t type, const uint64_t ignore, uint64_t * const flag_out) {
 
     if (!main) return;
 
index 9e2c7da614e87476329e5f4a91289bd228c2419b..6701818f7890b03c76f97c7b383c7cdd4c417a69 100644 (file)
@@ -20,27 +20,33 @@ extern "C" {
  *
  *   Must not be NULL.
  *
- *   This alters main.setting.state.status:
- *     F_okay on success.
- *     F_data_not on success but file is an empty string.
- *
- *     F_no (with error bit) on failure (not returned when simulating).
- *
- *     Errors (with error bit) from: f_directory_empty().
- *     Errors (with error bit) from: f_file_exists().
- *     Errors (with error bit) from: f_file_is().
- *     Errors (with error bit) from: f_file_stat().
- *     Errors (with error bit) from: kt_remove_preprocess_file_dates().
+ *   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_operate_*_e.
  * @param recurse
  *   One of the kt_remove_flag_recurse_*_d flags.
  *   Set to kt_remove_flag_recurse_none_d when this function is being called outside of directory recursion.
+ * @param flag_operate
+ *   The operate file specific flags from kt_remove_flag_operate_*_e for output.
+ *
+ *   This function initializes this variable.
+ *
+ *   Must not be NULL.
  *
  * @return
- *   The resulting flags determined by the pre-process.
+ *   F_okay on success.
+ *   F_data_not on success but file is an empty string.
+ *   F_no if the file does not exist or is not to be processed (but not due to an error).
+ *   F_skip if skipping the current path.
+ *
+ *   F_no (with error bit) on failure (not returned when simulating).
+ *   F_parameter (with error bit) if a parameter is invalid.
+ *
+ *   Errors (with error bit) from: f_directory_empty().
+ *   Errors (with error bit) from: f_file_exists().
+ *   Errors (with error bit) from: f_file_is().
+ *   Errors (with error bit) from: f_file_stat().
+ *   Errors (with error bit) from: kt_remove_preprocess_file_dates().
  *
  * @see f_directory_empty()
  * @see f_file_exists()
@@ -49,11 +55,11 @@ 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, const uint8_t recurse);
+  extern f_status_t kt_remove_preprocess_file(kt_remove_main_t * const main, const f_string_static_t path, const uint8_t recurse, uint64_t * const flag_operate);
 #endif // _di_kt_remove_preprocess_file_
 
 /**
- * Perform pre-processing (including simulation) of the file operation, specifically handling dates.
+ * Determine the read, write, and execute access permissions for some file for the current user.
  *
  * @param main
  *   The main program and settings data.
@@ -61,18 +67,54 @@ extern "C" {
  *   Must not be NULL.
  *
  *   This alters main.setting.state.status:
- *     F_yes on date matched.
- *     F_no on no matches.
- *     F_parameter (with error bit) if a parameter is invalid.
+ *     F_okay on success.
+ *     F_data_not on success but file is an empty string.
+ *
+ *     F_parameter (with error bit) on invalid parameter.
+ * @param path
+ *   The path to the file to operate on.
+ * @param flag_operate
+ *   The operate file specific flags from kt_remove_flag_operate_*_e.
+ *
+ *   Must not be NULL.
+ *
+ * @return
+ *   F_okay on success.
+ *   F_data_not on success but file is an empty string.
+ *
+ *   F_no (with error bit) on failure (not returned when simulating).
+ *   F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_kt_remove_preprocess_file_access_
+  extern f_status_t kt_remove_preprocess_file_access(kt_remove_main_t * const main, const f_string_static_t path, uint64_t * const flag_operate);
+#endif // _di_kt_remove_preprocess_file_access_
+
+/**
+ * Perform pre-processing (including simulation) of the file operation, specifically handling dates.
+ *
+ * @param main
+ *   The main program and settings data.
+ *
+ *   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_operate_*_e.
  * @param statistics
  *   The already loaded file statistics.
+ *
+ * @return
+ *   F_okay on success.
+ *   F_data_not on success but file is an empty string.
+ *   F_yes on date matched.
+ *   F_no on no matches.
+ *
+ *   F_parameter (with error bit) if a parameter is invalid.
  */
 #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 f_status_t kt_remove_preprocess_file_dates(kt_remove_main_t * const main, const f_string_static_t path, const uint64_t flag_operate, const struct stat statistics);
 #endif // _di_kt_remove_preprocess_file_dates_
 
 /**
@@ -111,7 +153,7 @@ extern "C" {
  *   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 uint8_t simulate, const f_string_static_t path, const uint8_t is, f_string_static_t name, const uint64_t type, const uint64_t ignore, 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 uint8_t is, f_string_static_t name, const uint64_t type, const uint64_t ignore, uint64_t * const flag_out);
 #endif // _di_kt_remove_preprocess_file_type_
 
 #ifdef __cplusplus
index e1958e886836d59bb930364bec49775d47637978..551fcf31d691c61053637413e090f973511d8155 100644 (file)
@@ -5,7 +5,7 @@ extern "C" {
 #endif
 
 #ifndef _di_kt_remove_print_debug_operate_file_remove_
-  f_status_t kt_remove_print_debug_operate_file_remove(fl_print_t * const print, const f_string_static_t path, const uint32_t flag) {
+  f_status_t kt_remove_print_debug_operate_file_remove(fl_print_t * const print, const f_string_static_t path, const uint64_t flag) {
 
     if (!print || !print->custom) return F_status_set_error(F_output_not);
 
index 28f64157fc355f9927ebe5da9c0676468515efe9..ddb8998231a5cfd750210c90de38ccb7db9e404a 100644 (file)
@@ -39,7 +39,7 @@ extern "C" {
  *   F_output_not (with error bit) if setting is NULL.
  */
 #ifndef _di_kt_remove_print_debug_operate_file_remove_
-  extern f_status_t kt_remove_print_debug_operate_file_remove(fl_print_t * const print, const f_string_static_t path, const uint32_t flag);
+  extern f_status_t kt_remove_print_debug_operate_file_remove(fl_print_t * const print, const f_string_static_t path, const uint64_t flag);
 #endif // _di_kt_remove_print_debug_operate_file_remove_
 
 #ifdef __cplusplus
index f233fe611df298800cdd92455e744b68648e597c..f783dc14587506196574077e19415cef578ecd4f 100644 (file)
@@ -28,7 +28,7 @@ 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 uint32_t flag_operate, const f_string_static_t name, const uint8_t yes) {
+  f_status_t kt_remove_print_simulate_operate_boolean(fl_print_t * const print, const uint64_t flag_operate, const f_string_static_t name, const uint8_t yes) {
 
     if (!print || !print->custom) return F_status_set_error(F_output_not);
 
@@ -43,7 +43,7 @@ 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 uint32_t flag_operate, const f_string_static_t name, const uint8_t 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 uint64_t flag_operate, const f_string_static_t name, const uint8_t 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);
 
@@ -70,7 +70,7 @@ 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 uint32_t flag_operate, const f_string_static_t path) {
+  f_status_t kt_remove_print_simulate_operate_file(fl_print_t * const print, const uint64_t flag_operate, const f_string_static_t path) {
 
     if (!print || !print->custom) return F_status_set_error(F_output_not);
 
@@ -84,8 +84,49 @@ extern "C" {
   }
 #endif // _di_kt_remove_print_simulate_operate_file_
 
+#ifndef _di_kt_remove_print_simulate_operate_file_access_
+  f_status_t kt_remove_print_simulate_operate_file_access(fl_print_t * const print, const uint64_t flag_operate, const f_string_static_t path) {
+
+    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) || (flag_operate & kt_remove_flag_operate_simulate_not_d)) return F_output_not;
+
+    f_file_stream_lock(print->to);
+
+    fl_print_format("  %r ", print->to, kt_remove_access_s);
+
+    if (flag_operate & kt_remove_flag_operate_unable_read_d) {
+      f_print_dynamic(kt_remove_print_reason_cannot_read_s, print->to);
+
+      if (flag_operate & kt_remove_flag_operate_unable_wx_d) {
+        f_print_dynamic(kt_remove_comma_space_s, print->to);
+      }
+    }
+
+    if (flag_operate & kt_remove_flag_operate_unable_write_d) {
+      f_print_dynamic(kt_remove_print_reason_cannot_write_s, print->to);
+
+      if (flag_operate & kt_remove_flag_operate_unable_execute_d) {
+        f_print_dynamic(kt_remove_comma_space_s, print->to);
+      }
+    }
+
+    if (flag_operate & kt_remove_flag_operate_unable_execute_d) {
+      f_print_dynamic(kt_remove_print_reason_cannot_execute_s, print->to);
+    }
+
+    f_print_dynamic(f_string_eol_s, print->to);
+
+    f_file_stream_unlock(print->to);
+
+    return F_okay;
+  }
+#endif // _di_kt_remove_print_simulate_operate_file_access_
+
 #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 uint32_t flag_operate, const f_string_static_t path, const f_status_t exists) {
+  f_status_t kt_remove_print_simulate_operate_file_exists(fl_print_t * const print, const uint64_t flag_operate, const f_string_static_t path, const f_status_t exists) {
 
     if (!print || !print->custom) return F_status_set_error(F_output_not);
 
@@ -125,7 +166,7 @@ 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 uint32_t flag_operate, const f_number_unsigned_t id, const uint8_t is_user) {
+  f_status_t kt_remove_print_simulate_operate_id(fl_print_t * const print, const uint64_t flag_operate, const f_number_unsigned_t id, const uint8_t is_user) {
 
     if (!print || !print->custom) return F_status_set_error(F_output_not);
 
@@ -140,7 +181,7 @@ 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 uint32_t flag_operate, 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 uint64_t flag_operate, const f_number_unsigned_t mode, const f_string_static_t match) {
 
     if (!print || !print->custom) return F_status_set_error(F_output_not);
 
@@ -158,6 +199,23 @@ extern "C" {
     return F_okay;
   }
 #endif // _di_kt_remove_print_simulate_operate_mode_
+
+#ifndef _di_kt_remove_print_simulate_operate_unknown_
+  f_status_t kt_remove_print_simulate_operate_unknown(fl_print_t * const print, const uint64_t flag_operate, const f_string_static_t name) {
+
+    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) || (flag_operate & kt_remove_flag_operate_simulate_not_d)) return F_output_not;
+
+    fll_print_format("  %r %r%r", print->to, name, kt_remove_unknown_s, f_string_eol_s);
+
+    return F_okay;
+  }
+#endif // _di_kt_remove_print_simulate_operate_unknown_
+
+
 #ifdef __cplusplus
 } // extern "C"
 #endif
index 6f1b47061e052275b73c5949bb9a5dff32ad7ae4..edf9f721d3cfe0dab7c50efa00e1877606bc1143 100644 (file)
@@ -68,7 +68,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 uint32_t flag_operate, const f_string_static_t name, const uint8_t yes);
+  extern f_status_t kt_remove_print_simulate_operate_boolean(fl_print_t * const print, const uint64_t flag_operate, const f_string_static_t name, const uint8_t yes);
 #endif // _di_kt_remove_print_simulate_operate_boolean_
 
 /**
@@ -105,11 +105,11 @@ 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 uint32_t flag_operate, const f_string_static_t name, const uint8_t 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 uint64_t flag_operate, const f_string_static_t name, const uint8_t 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_
 
 /**
- * Simulate operate on a single file.
+ * Print message about operating on a file.
  *
  * This does nothing if the simulate flag (kt_remove_flag_simulate_d) is not set.
  *
@@ -133,10 +133,38 @@ 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 uint32_t flag_operate, const f_string_static_t path);
+  extern f_status_t kt_remove_print_simulate_operate_file(fl_print_t * const print, const uint64_t flag_operate, const f_string_static_t path);
 #endif // _di_kt_remove_print_simulate_operate_file_
 
 /**
+ * Print message about file access problems.
+ *
+ * This does nothing if the simulate flag (kt_remove_flag_simulate_d) is not set.
+ *
+ * @param print
+ *   The output structure to print to.
+ *
+ *   This locks, uses, and unlocks the file stream.
+ *
+ *   Must not be NULL.
+ *
+ *   This does not alter print.custom.setting.state.status.
+ * @param flag_operate
+ *   The operate file specific flags from kt_remove_flag_operate_*_e.
+ * @param path
+ *   The path to the file to operate on.
+ *
+ * @return
+ *   F_okay on success.
+ *   F_output_not on success, but no printing is performed.
+ *
+ *   F_output_not (with error bit) if setting is NULL.
+ */
+#ifndef _di_kt_remove_print_simulate_operate_file_access_
+  extern f_status_t kt_remove_print_simulate_operate_file_access(fl_print_t * const print, const uint64_t flag_operate, const f_string_static_t path);
+#endif // _di_kt_remove_print_simulate_operate_file_access_
+
+/**
  * Simulate operate on a single file, processing file existence.
  *
  * This does nothing if the simulate flag (kt_remove_flag_simulate_d) is not set.
@@ -166,7 +194,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 uint32_t flag_operate, const f_string_static_t path, const f_status_t exists);
+  extern f_status_t kt_remove_print_simulate_operate_file_exists(fl_print_t * const print, const uint64_t flag_operate, const f_string_static_t path, const f_status_t exists);
 #endif // _di_kt_remove_print_simulate_operate_file_exists_
 
 /**
@@ -197,7 +225,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 uint32_t flag_operate, const f_number_unsigned_t id, const uint8_t is_user);
+  extern f_status_t kt_remove_print_simulate_operate_id(fl_print_t * const print, const uint64_t flag_operate, const f_number_unsigned_t id, const uint8_t is_user);
 #endif // _di_kt_remove_print_simulate_operate_id_
 
 /**
@@ -228,9 +256,37 @@ 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 uint32_t flag_operate, 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 uint64_t flag_operate, const f_number_unsigned_t mode, const f_string_static_t match);
 #endif // _di_kt_remove_print_simulate_operate_mode_
 
+/**
+ * Print a "unknown" for some named parameter regarding the simulation.
+ *
+ * This does nothing if the simulate flag (kt_remove_flag_simulate_d) is not set.
+ *
+ * @param print
+ *   The output structure to print to.
+ *
+ *   This locks, uses, and unlocks the file stream.
+ *
+ *   Must not be NULL.
+ *
+ *   This does not alter print.custom.setting.state.status.
+ * @param flag_operate
+ *   The operate file specific flags from kt_remove_flag_operate_*_e.
+ * @param name
+ *   The name to be associated with the boolean value.
+ *
+ * @return
+ *   F_okay on success.
+ *   F_output_not on success, but no printing is performed.
+ *
+ *   F_output_not (with error bit) if setting is NULL.
+ */
+#ifndef _di_kt_remove_print_simulate_operate_unknown_
+  extern f_status_t kt_remove_print_simulate_operate_unknown(fl_print_t * const print, const uint64_t flag_operate, const f_string_static_t name);
+#endif // _di_kt_remove_print_simulate_operate_unknown_
+
 #ifdef __cplusplus
 } // extern "C"
 #endif
index 114a7d0ef01af01f0925cdbfa6f5614025b128d2..f57342a96077fe601cfa3e8847ff887f4aa290a2 100644 (file)
@@ -5,7 +5,7 @@ extern "C" {
 #endif
 
 #ifndef _di_kt_remove_print_verbose_operate_file_remove_
-  f_status_t kt_remove_print_verbose_operate_file_remove(fl_print_t * const print, const f_string_static_t path, const uint32_t flag) {
+  f_status_t kt_remove_print_verbose_operate_file_remove(fl_print_t * const print, const f_string_static_t path, const uint64_t flag) {
 
     if (!print || !print->custom) return F_status_set_error(F_output_not);
 
index 02f96b023baac76810e2a934ba92dad350493d56..9551d656e66b28fa15c866f61413e60fe7452fb3 100644 (file)
@@ -39,7 +39,7 @@ extern "C" {
  *   F_output_not (with error bit) if setting is NULL.
  */
 #ifndef _di_kt_remove_print_verbose_operate_file_remove_
-  extern f_status_t kt_remove_print_verbose_operate_file_remove(fl_print_t * const print, const f_string_static_t path, const uint32_t flag);
+  extern f_status_t kt_remove_print_verbose_operate_file_remove(fl_print_t * const print, const f_string_static_t path, const uint64_t flag);
 #endif // _di_kt_remove_print_verbose_operate_file_remove_
 
 #ifdef __cplusplus
index 7fc96d5873c0e043bcfd14249394992976508c9e..cc170d9badd64f95793701aa107b29a3cab74c62 100644 (file)
@@ -62,10 +62,15 @@ extern "C" {
     main->setting.state.status = F_okay;
 
     f_number_unsigned_t i = 0;
+    uint64_t flag_operate = 0;
 
     for (; i < main->setting.files.used; ++i) {
 
-      main->setting.state.status = kt_remove_operate_file(main, main->setting.files.array[i], kt_remove_flag_recurse_top_d);
+      main->setting.state.status = kt_remove_preprocess_file(main, main->setting.files.array[i], 0, &flag_operate);
+
+      if (F_status_is_error_not(main->setting.state.status)) {
+        main->setting.state.status = kt_remove_operate_file(main, main->setting.files.array[i], 0, flag_operate);
+      }
 
       if (F_status_is_error(main->setting.state.status)) {
         if (F_status_set_fine(main->setting.state.status) == F_interrupt) {
@@ -73,7 +78,7 @@ extern "C" {
         }
 
         // If told to skip all, then do not return as an error.
-        if (F_status_set_fine(main->setting.state.status) == F_skip) {
+        else if (F_status_set_fine(main->setting.state.status) == F_skip) {
           main->setting.state.status = F_okay;
         }
 
@@ -84,10 +89,20 @@ extern "C" {
     if (main->cache.tree.used) {
       for (i = 0; i < main->cache.tree.used; ++i) {
 
-        kt_remove_operate_file_parent(main, main->cache.tree.array[i]);
+        main->setting.state.status = kt_remove_preprocess_file(main, main->cache.tree.array[i], 0, &flag_operate);
+
+        if (F_status_is_error_not(main->setting.state.status)) {
+          kt_remove_operate_file_parent(main, main->cache.tree.array[i], flag_operate);
+        }
+
         if (F_status_is_error(main->setting.state.status)) return;
       } // for
     }
+
+    // One or more files failed to be deleted on error.
+    if (main->setting.flag & kt_remove_main_flag_return_fail_d) {
+      main->setting.state.status = F_status_set_error(F_no);
+    }
   }
 #endif // _di_kt_remove_normal_operate_
 
index bc9b73b8fe844802641379abf7fe4d04343b6d0f..77374830f342960dcfcfac3c7375086fe3d8d124 100644 (file)
@@ -39,6 +39,10 @@ f_status_t __wrap_f_directory_remove(const f_string_static_t path, const int dep
   return mock_type(f_status_t);
 }
 
+f_status_t __wrap_f_file_access(const f_string_static_t path, const int mode) {
+  return mock_type(f_status_t);
+}
+
 f_status_t __wrap_f_file_exists(const f_string_static_t path, const uint8_t dereference) {
   return mock_type(f_status_t);
 }
@@ -77,17 +81,18 @@ void __wrap_fl_directory_do(const f_string_static_t path, f_directory_recurse_do
 
   if (!recurse) return;
 
-  const uint32_t total = mock_type(uint32_t);
+  const uint64_t total = mock_type(uint64_t);
 
   if (total) {
-    for (uint32_t i = 0; i < total; ++i) {
+    for (uint64_t i = 0; i < total; ++i) {
 
       f_string_static_t * const child_path = mock_ptr_type(f_string_static_t *);
       f_string_static_t * const child_name = mock_ptr_type(f_string_static_t *);
 
       recurse->path = child_path ? *child_path : f_string_empty_s;
+      recurse->depth = mock_type(uint64_t);
 
-      recurse->action(recurse, child_name ? *child_name : f_string_empty_s, mock_type(uint32_t));
+      recurse->action(recurse, child_name ? *child_name : f_string_empty_s, mock_type(uint64_t));
     } // for
   }
   else {
index 5f555d43864a0d42ae6bd14fcd86b3bd8bce50ff..96d18169bea7a8210b94158a791219bd05d9add5 100644 (file)
@@ -44,6 +44,7 @@ extern f_status_t __wrap_f_account_id_by_name(const f_string_static_t name, f_ui
 extern f_status_t __wrap_f_directory_empty(const f_string_static_t path);
 extern f_status_t __wrap_f_directory_remove(const f_string_static_t path, const int depth_max, const uint8_t preserve);
 
+extern f_status_t __wrap_f_file_access(const f_string_static_t path, const int mode);
 extern f_status_t __wrap_f_file_exists(const f_string_static_t path, const uint8_t dereference);
 extern f_status_t __wrap_f_file_is(const f_string_static_t path, const int type, const uint8_t dereference);
 extern f_status_t __wrap_f_file_remove(const f_string_static_t path);
index 005fe03e7cab1bfa1509ee3ac482e13f7c94ce24..ae5eecd246bd89b048e888df4b4555f9ccb2f6fc 100644 (file)
@@ -132,6 +132,9 @@ void test__kt_remove__date_accessed__date_works(void **state) {
           will_return(__wrap_f_file_is, macro_f_file_type_is_link(stats[type].st_mode));
           will_return(__wrap_f_file_stat, &stats[type]);
           will_return(__wrap_f_file_stat, F_okay);
+          will_return(__wrap_f_file_access, F_true);
+          will_return(__wrap_f_file_access, F_true);
+          will_return(__wrap_f_file_access, F_true);
 
           if (macro_f_file_type_is_directory(stats[type].st_mode)) {
             will_return(__wrap_f_directory_empty, F_true);
@@ -139,19 +142,12 @@ void test__kt_remove__date_accessed__date_works(void **state) {
             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, 0);
             will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_d | f_directory_recurse_do_flag_directory_d);
           }
 
           if (time_spec_removes[date]) {
             if (macro_f_file_type_is_directory(stats[type].st_mode)) {
-
-              // 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, macro_f_file_type_is_link(stats[type].st_mode));
-              will_return(__wrap_f_file_stat, &stats[type]);
-              will_return(__wrap_f_file_stat, F_okay);
-              will_return(__wrap_f_directory_empty, F_true);
-
               will_return(__wrap_f_directory_remove, F_okay);
             }
             else {
@@ -293,6 +289,9 @@ void test__kt_remove__date_accessed__now_works(void **state) {
         will_return(__wrap_f_file_is, macro_f_file_type_is_link(stats[type].st_mode));
         will_return(__wrap_f_file_stat, &stats[type]);
         will_return(__wrap_f_file_stat, F_okay);
+        will_return(__wrap_f_file_access, F_true);
+        will_return(__wrap_f_file_access, F_true);
+        will_return(__wrap_f_file_access, F_true);
 
         if (macro_f_file_type_is_directory(stats[type].st_mode)) {
           will_return(__wrap_f_directory_empty, F_true);
@@ -305,19 +304,12 @@ void test__kt_remove__date_accessed__now_works(void **state) {
           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, 0);
           will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_d | f_directory_recurse_do_flag_directory_d);
         }
 
         if (time_spec_removes[date]) {
           if (macro_f_file_type_is_directory(stats[type].st_mode)) {
-
-            // 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, macro_f_file_type_is_link(stats[type].st_mode));
-            will_return(__wrap_f_file_stat, &stats[type]);
-            will_return(__wrap_f_file_stat, F_okay);
-            will_return(__wrap_f_directory_empty, F_true);
-
             will_return(__wrap_f_directory_remove, F_okay);
           }
           else {
@@ -458,6 +450,9 @@ void test__kt_remove__date_accessed__today_works(void **state) {
         will_return(__wrap_f_file_is, macro_f_file_type_is_link(stats[type].st_mode));
         will_return(__wrap_f_file_stat, &stats[type]);
         will_return(__wrap_f_file_stat, F_okay);
+        will_return(__wrap_f_file_access, F_true);
+        will_return(__wrap_f_file_access, F_true);
+        will_return(__wrap_f_file_access, F_true);
 
         if (macro_f_file_type_is_directory(stats[type].st_mode)) {
           will_return(__wrap_f_directory_empty, F_true);
@@ -470,19 +465,12 @@ void test__kt_remove__date_accessed__today_works(void **state) {
           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, 0);
           will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_d | f_directory_recurse_do_flag_directory_d);
         }
 
         if (time_spec_removes[date]) {
           if (macro_f_file_type_is_directory(stats[type].st_mode)) {
-
-            // 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, macro_f_file_type_is_link(stats[type].st_mode));
-            will_return(__wrap_f_file_stat, &stats[type]);
-            will_return(__wrap_f_file_stat, F_okay);
-            will_return(__wrap_f_directory_empty, F_true);
-
             will_return(__wrap_f_directory_remove, F_okay);
           }
           else {
@@ -623,6 +611,9 @@ void test__kt_remove__date_accessed__tomorrow_works(void **state) {
         will_return(__wrap_f_file_is, macro_f_file_type_is_link(stats[type].st_mode));
         will_return(__wrap_f_file_stat, &stats[type]);
         will_return(__wrap_f_file_stat, F_okay);
+        will_return(__wrap_f_file_access, F_true);
+        will_return(__wrap_f_file_access, F_true);
+        will_return(__wrap_f_file_access, F_true);
 
         if (macro_f_file_type_is_directory(stats[type].st_mode)) {
           will_return(__wrap_f_directory_empty, F_true);
@@ -635,19 +626,12 @@ void test__kt_remove__date_accessed__tomorrow_works(void **state) {
           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, 0);
           will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_d | f_directory_recurse_do_flag_directory_d);
         }
 
         if (time_spec_removes[date]) {
           if (macro_f_file_type_is_directory(stats[type].st_mode)) {
-
-            // 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, macro_f_file_type_is_link(stats[type].st_mode));
-            will_return(__wrap_f_file_stat, &stats[type]);
-            will_return(__wrap_f_file_stat, F_okay);
-            will_return(__wrap_f_directory_empty, F_true);
-
             will_return(__wrap_f_directory_remove, F_okay);
           }
           else {
@@ -788,6 +772,9 @@ void test__kt_remove__date_accessed__yesterday_works(void **state) {
         will_return(__wrap_f_file_is, macro_f_file_type_is_link(stats[type].st_mode));
         will_return(__wrap_f_file_stat, &stats[type]);
         will_return(__wrap_f_file_stat, F_okay);
+        will_return(__wrap_f_file_access, F_true);
+        will_return(__wrap_f_file_access, F_true);
+        will_return(__wrap_f_file_access, F_true);
 
         if (macro_f_file_type_is_directory(stats[type].st_mode)) {
           will_return(__wrap_f_directory_empty, F_true);
@@ -800,19 +787,12 @@ void test__kt_remove__date_accessed__yesterday_works(void **state) {
           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, 0);
           will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_d | f_directory_recurse_do_flag_directory_d);
         }
 
         if (time_spec_removes[date]) {
           if (macro_f_file_type_is_directory(stats[type].st_mode)) {
-
-            // 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, macro_f_file_type_is_link(stats[type].st_mode));
-            will_return(__wrap_f_file_stat, &stats[type]);
-            will_return(__wrap_f_file_stat, F_okay);
-            will_return(__wrap_f_directory_empty, F_true);
-
             will_return(__wrap_f_directory_remove, F_okay);
           }
           else {
index 2c1aea34ecf5cbfb356f3e3ec67e48e3a9599658..ba95e47cfe773c96c9625186bff9dac56e279731 100644 (file)
@@ -132,6 +132,9 @@ void test__kt_remove__date_changed__date_works(void **state) {
           will_return(__wrap_f_file_is, macro_f_file_type_is_link(stats[type].st_mode));
           will_return(__wrap_f_file_stat, &stats[type]);
           will_return(__wrap_f_file_stat, F_okay);
+          will_return(__wrap_f_file_access, F_true);
+          will_return(__wrap_f_file_access, F_true);
+          will_return(__wrap_f_file_access, F_true);
 
           if (macro_f_file_type_is_directory(stats[type].st_mode)) {
             will_return(__wrap_f_directory_empty, F_true);
@@ -139,19 +142,12 @@ void test__kt_remove__date_changed__date_works(void **state) {
             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, 0);
             will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_d | f_directory_recurse_do_flag_directory_d);
           }
 
           if (time_spec_removes[date]) {
             if (macro_f_file_type_is_directory(stats[type].st_mode)) {
-
-              // 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, macro_f_file_type_is_link(stats[type].st_mode));
-              will_return(__wrap_f_file_stat, &stats[type]);
-              will_return(__wrap_f_file_stat, F_okay);
-              will_return(__wrap_f_directory_empty, F_true);
-
               will_return(__wrap_f_directory_remove, F_okay);
             }
             else {
@@ -293,6 +289,9 @@ void test__kt_remove__date_changed__now_works(void **state) {
         will_return(__wrap_f_file_is, macro_f_file_type_is_link(stats[type].st_mode));
         will_return(__wrap_f_file_stat, &stats[type]);
         will_return(__wrap_f_file_stat, F_okay);
+        will_return(__wrap_f_file_access, F_true);
+        will_return(__wrap_f_file_access, F_true);
+        will_return(__wrap_f_file_access, F_true);
 
         if (macro_f_file_type_is_directory(stats[type].st_mode)) {
           will_return(__wrap_f_directory_empty, F_true);
@@ -305,19 +304,12 @@ void test__kt_remove__date_changed__now_works(void **state) {
           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, 0);
           will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_d | f_directory_recurse_do_flag_directory_d);
         }
 
         if (time_spec_removes[date]) {
           if (macro_f_file_type_is_directory(stats[type].st_mode)) {
-
-            // 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, macro_f_file_type_is_link(stats[type].st_mode));
-            will_return(__wrap_f_file_stat, &stats[type]);
-            will_return(__wrap_f_file_stat, F_okay);
-            will_return(__wrap_f_directory_empty, F_true);
-
             will_return(__wrap_f_directory_remove, F_okay);
           }
           else {
@@ -458,6 +450,9 @@ void test__kt_remove__date_changed__today_works(void **state) {
         will_return(__wrap_f_file_is, macro_f_file_type_is_link(stats[type].st_mode));
         will_return(__wrap_f_file_stat, &stats[type]);
         will_return(__wrap_f_file_stat, F_okay);
+        will_return(__wrap_f_file_access, F_true);
+        will_return(__wrap_f_file_access, F_true);
+        will_return(__wrap_f_file_access, F_true);
 
         if (macro_f_file_type_is_directory(stats[type].st_mode)) {
           will_return(__wrap_f_directory_empty, F_true);
@@ -470,19 +465,12 @@ void test__kt_remove__date_changed__today_works(void **state) {
           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, 0);
           will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_d | f_directory_recurse_do_flag_directory_d);
         }
 
         if (time_spec_removes[date]) {
           if (macro_f_file_type_is_directory(stats[type].st_mode)) {
-
-            // 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, macro_f_file_type_is_link(stats[type].st_mode));
-            will_return(__wrap_f_file_stat, &stats[type]);
-            will_return(__wrap_f_file_stat, F_okay);
-            will_return(__wrap_f_directory_empty, F_true);
-
             will_return(__wrap_f_directory_remove, F_okay);
           }
           else {
@@ -623,6 +611,9 @@ void test__kt_remove__date_changed__tomorrow_works(void **state) {
         will_return(__wrap_f_file_is, macro_f_file_type_is_link(stats[type].st_mode));
         will_return(__wrap_f_file_stat, &stats[type]);
         will_return(__wrap_f_file_stat, F_okay);
+        will_return(__wrap_f_file_access, F_true);
+        will_return(__wrap_f_file_access, F_true);
+        will_return(__wrap_f_file_access, F_true);
 
         if (macro_f_file_type_is_directory(stats[type].st_mode)) {
           will_return(__wrap_f_directory_empty, F_true);
@@ -635,19 +626,12 @@ void test__kt_remove__date_changed__tomorrow_works(void **state) {
           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, 0);
           will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_d | f_directory_recurse_do_flag_directory_d);
         }
 
         if (time_spec_removes[date]) {
           if (macro_f_file_type_is_directory(stats[type].st_mode)) {
-
-            // 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, macro_f_file_type_is_link(stats[type].st_mode));
-            will_return(__wrap_f_file_stat, &stats[type]);
-            will_return(__wrap_f_file_stat, F_okay);
-            will_return(__wrap_f_directory_empty, F_true);
-
             will_return(__wrap_f_directory_remove, F_okay);
           }
           else {
@@ -788,6 +772,9 @@ void test__kt_remove__date_changed__yesterday_works(void **state) {
         will_return(__wrap_f_file_is, macro_f_file_type_is_link(stats[type].st_mode));
         will_return(__wrap_f_file_stat, &stats[type]);
         will_return(__wrap_f_file_stat, F_okay);
+        will_return(__wrap_f_file_access, F_true);
+        will_return(__wrap_f_file_access, F_true);
+        will_return(__wrap_f_file_access, F_true);
 
         if (macro_f_file_type_is_directory(stats[type].st_mode)) {
           will_return(__wrap_f_directory_empty, F_true);
@@ -800,19 +787,12 @@ void test__kt_remove__date_changed__yesterday_works(void **state) {
           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, 0);
           will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_d | f_directory_recurse_do_flag_directory_d);
         }
 
         if (time_spec_removes[date]) {
           if (macro_f_file_type_is_directory(stats[type].st_mode)) {
-
-            // 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, macro_f_file_type_is_link(stats[type].st_mode));
-            will_return(__wrap_f_file_stat, &stats[type]);
-            will_return(__wrap_f_file_stat, F_okay);
-            will_return(__wrap_f_directory_empty, F_true);
-
             will_return(__wrap_f_directory_remove, F_okay);
           }
           else {
index c53ddd252e7d290a2befd4469758724d4fe45996..0428aaf4de35db3e9976a5e27791ae3121dd6c5c 100644 (file)
@@ -132,6 +132,9 @@ void test__kt_remove__date_updated__date_works(void **state) {
           will_return(__wrap_f_file_is, macro_f_file_type_is_link(stats[type].st_mode));
           will_return(__wrap_f_file_stat, &stats[type]);
           will_return(__wrap_f_file_stat, F_okay);
+          will_return(__wrap_f_file_access, F_true);
+          will_return(__wrap_f_file_access, F_true);
+          will_return(__wrap_f_file_access, F_true);
 
           if (macro_f_file_type_is_directory(stats[type].st_mode)) {
             will_return(__wrap_f_directory_empty, F_true);
@@ -139,19 +142,12 @@ void test__kt_remove__date_updated__date_works(void **state) {
             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, 0);
             will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_d | f_directory_recurse_do_flag_directory_d);
           }
 
           if (time_spec_removes[date]) {
             if (macro_f_file_type_is_directory(stats[type].st_mode)) {
-
-              // 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, macro_f_file_type_is_link(stats[type].st_mode));
-              will_return(__wrap_f_file_stat, &stats[type]);
-              will_return(__wrap_f_file_stat, F_okay);
-              will_return(__wrap_f_directory_empty, F_true);
-
               will_return(__wrap_f_directory_remove, F_okay);
             }
             else {
@@ -293,6 +289,9 @@ void test__kt_remove__date_updated__now_works(void **state) {
         will_return(__wrap_f_file_is, macro_f_file_type_is_link(stats[type].st_mode));
         will_return(__wrap_f_file_stat, &stats[type]);
         will_return(__wrap_f_file_stat, F_okay);
+        will_return(__wrap_f_file_access, F_true);
+        will_return(__wrap_f_file_access, F_true);
+        will_return(__wrap_f_file_access, F_true);
 
         if (macro_f_file_type_is_directory(stats[type].st_mode)) {
           will_return(__wrap_f_directory_empty, F_true);
@@ -305,19 +304,12 @@ void test__kt_remove__date_updated__now_works(void **state) {
           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, 0);
           will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_d | f_directory_recurse_do_flag_directory_d);
         }
 
         if (time_spec_removes[date]) {
           if (macro_f_file_type_is_directory(stats[type].st_mode)) {
-
-            // 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, macro_f_file_type_is_link(stats[type].st_mode));
-            will_return(__wrap_f_file_stat, &stats[type]);
-            will_return(__wrap_f_file_stat, F_okay);
-            will_return(__wrap_f_directory_empty, F_true);
-
             will_return(__wrap_f_directory_remove, F_okay);
           }
           else {
@@ -458,6 +450,9 @@ void test__kt_remove__date_updated__today_works(void **state) {
         will_return(__wrap_f_file_is, macro_f_file_type_is_link(stats[type].st_mode));
         will_return(__wrap_f_file_stat, &stats[type]);
         will_return(__wrap_f_file_stat, F_okay);
+        will_return(__wrap_f_file_access, F_true);
+        will_return(__wrap_f_file_access, F_true);
+        will_return(__wrap_f_file_access, F_true);
 
         if (macro_f_file_type_is_directory(stats[type].st_mode)) {
           will_return(__wrap_f_directory_empty, F_true);
@@ -470,19 +465,12 @@ void test__kt_remove__date_updated__today_works(void **state) {
           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, 0);
           will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_d | f_directory_recurse_do_flag_directory_d);
         }
 
         if (time_spec_removes[date]) {
           if (macro_f_file_type_is_directory(stats[type].st_mode)) {
-
-            // 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, macro_f_file_type_is_link(stats[type].st_mode));
-            will_return(__wrap_f_file_stat, &stats[type]);
-            will_return(__wrap_f_file_stat, F_okay);
-            will_return(__wrap_f_directory_empty, F_true);
-
             will_return(__wrap_f_directory_remove, F_okay);
           }
           else {
@@ -623,6 +611,9 @@ void test__kt_remove__date_updated__tomorrow_works(void **state) {
         will_return(__wrap_f_file_is, macro_f_file_type_is_link(stats[type].st_mode));
         will_return(__wrap_f_file_stat, &stats[type]);
         will_return(__wrap_f_file_stat, F_okay);
+        will_return(__wrap_f_file_access, F_true);
+        will_return(__wrap_f_file_access, F_true);
+        will_return(__wrap_f_file_access, F_true);
 
         if (macro_f_file_type_is_directory(stats[type].st_mode)) {
           will_return(__wrap_f_directory_empty, F_true);
@@ -635,19 +626,12 @@ void test__kt_remove__date_updated__tomorrow_works(void **state) {
           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, 0);
           will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_d | f_directory_recurse_do_flag_directory_d);
         }
 
         if (time_spec_removes[date]) {
           if (macro_f_file_type_is_directory(stats[type].st_mode)) {
-
-            // 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, macro_f_file_type_is_link(stats[type].st_mode));
-            will_return(__wrap_f_file_stat, &stats[type]);
-            will_return(__wrap_f_file_stat, F_okay);
-            will_return(__wrap_f_directory_empty, F_true);
-
             will_return(__wrap_f_directory_remove, F_okay);
           }
           else {
@@ -788,6 +772,9 @@ void test__kt_remove__date_updated__yesterday_works(void **state) {
         will_return(__wrap_f_file_is, macro_f_file_type_is_link(stats[type].st_mode));
         will_return(__wrap_f_file_stat, &stats[type]);
         will_return(__wrap_f_file_stat, F_okay);
+        will_return(__wrap_f_file_access, F_true);
+        will_return(__wrap_f_file_access, F_true);
+        will_return(__wrap_f_file_access, F_true);
 
         if (macro_f_file_type_is_directory(stats[type].st_mode)) {
           will_return(__wrap_f_directory_empty, F_true);
@@ -800,19 +787,12 @@ void test__kt_remove__date_updated__yesterday_works(void **state) {
           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, 0);
           will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_d | f_directory_recurse_do_flag_directory_d);
         }
 
         if (time_spec_removes[date]) {
           if (macro_f_file_type_is_directory(stats[type].st_mode)) {
-
-            // 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, macro_f_file_type_is_link(stats[type].st_mode));
-            will_return(__wrap_f_file_stat, &stats[type]);
-            will_return(__wrap_f_file_stat, F_okay);
-            will_return(__wrap_f_directory_empty, F_true);
-
             will_return(__wrap_f_directory_remove, F_okay);
           }
           else {
index 75f61f2334ed822f6133898f12480209444b8f5c..b0dd8d81ec037affea1b7ae5f297a2ec18a3759c 100644 (file)
@@ -14,34 +14,31 @@ void test__kt_remove__directory_no_args__one_empty_exists_link(void **state) {
 
   const f_string_static_t target = macro_f_string_static_t_initialize_1("to_remove", 0, 9);
 
-  struct stat statistics;
+  struct stat stat_directory;
 
   {
     const f_string_t argv[] = { "mocked_main", target.string, 0 };
 
-    memset(&statistics, 0, sizeof(struct stat));
-    statistics.st_mode = F_file_mode_all_d | F_file_type_directory_d; // Should result in kt_remove_flag_operate_remove_d.
+    memset(&stat_directory, 0, sizeof(struct stat));
+    stat_directory.st_mode = F_file_mode_all_d | F_file_type_directory_d; // Should result in kt_remove_flag_operate_remove_d.
 
     // Pre-process target.
     will_return(__wrap_f_file_exists, F_true);
     will_return(__wrap_f_file_is, F_true); // A link, kt_remove_flag_operate_link_d is set.
-    will_return(__wrap_f_file_stat, &statistics);
+    will_return(__wrap_f_file_stat, &stat_directory);
     will_return(__wrap_f_file_stat, F_okay);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
 
     // Directory processing.
     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, 0);
     will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_d | f_directory_recurse_do_flag_directory_d);
 
-    // 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, macro_f_file_type_is_link(statistics.st_mode));
-    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);
 
@@ -53,29 +50,26 @@ void test__kt_remove__directory_no_args__one_empty_exists_link(void **state) {
   {
     const f_string_t argv[] = { "mocked_main", target.string, "+" F_console_standard_short_verbose_s, 0 };
 
-    memset(&statistics, 0, sizeof(struct stat));
-    statistics.st_mode = F_file_mode_all_d | F_file_type_directory_d; // Should result in kt_remove_flag_operate_remove_d.
+    memset(&stat_directory, 0, sizeof(struct stat));
+    stat_directory.st_mode = F_file_mode_all_d | F_file_type_directory_d; // Should result in kt_remove_flag_operate_remove_d.
 
     // Pre-process target.
     will_return(__wrap_f_file_exists, F_true);
     will_return(__wrap_f_file_is, F_true); // A link, kt_remove_flag_operate_link_d is set.
-    will_return(__wrap_f_file_stat, &statistics);
+    will_return(__wrap_f_file_stat, &stat_directory);
     will_return(__wrap_f_file_stat, F_okay);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
 
     // Directory processing.
     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, 0);
     will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_d | f_directory_recurse_do_flag_directory_d);
 
-    // 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, macro_f_file_type_is_link(statistics.st_mode));
-    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);
 
@@ -87,29 +81,26 @@ void test__kt_remove__directory_no_args__one_empty_exists_link(void **state) {
   {
     const f_string_t argv[] = { "mocked_main", target.string, "+" F_console_standard_short_debug_s, 0 };
 
-    memset(&statistics, 0, sizeof(struct stat));
-    statistics.st_mode = F_file_mode_all_d | F_file_type_directory_d; // Should result in kt_remove_flag_operate_remove_d.
+    memset(&stat_directory, 0, sizeof(struct stat));
+    stat_directory.st_mode = F_file_mode_all_d | F_file_type_directory_d; // Should result in kt_remove_flag_operate_remove_d.
 
     // Pre-process target.
     will_return(__wrap_f_file_exists, F_true);
     will_return(__wrap_f_file_is, F_true); // A link, kt_remove_flag_operate_link_d is set.
-    will_return(__wrap_f_file_stat, &statistics);
+    will_return(__wrap_f_file_stat, &stat_directory);
     will_return(__wrap_f_file_stat, F_okay);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
 
     // Directory processing.
     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, 0);
     will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_d | f_directory_recurse_do_flag_directory_d);
 
-    // 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, macro_f_file_type_is_link(statistics.st_mode));
-    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);
 
@@ -126,34 +117,31 @@ void test__kt_remove__directory_no_args__one_empty_exists_link_not(void **state)
 
   const f_string_static_t target = macro_f_string_static_t_initialize_1("to_remove", 0, 9);
 
-  struct stat statistics;
+  struct stat stat_directory;
 
   {
     const f_string_t argv[] = { "mocked_main", target.string, 0 };
 
-    memset(&statistics, 0, sizeof(struct stat));
-    statistics.st_mode = F_file_mode_all_d | F_file_type_directory_d; // Should result in kt_remove_flag_operate_remove_d.
+    memset(&stat_directory, 0, sizeof(struct stat));
+    stat_directory.st_mode = F_file_mode_all_d | F_file_type_directory_d; // Should result in kt_remove_flag_operate_remove_d.
 
     // Pre-process target.
     will_return(__wrap_f_file_exists, F_true);
     will_return(__wrap_f_file_is, F_false); // Not a link, kt_remove_flag_operate_link_d is not set.
-    will_return(__wrap_f_file_stat, &statistics);
+    will_return(__wrap_f_file_stat, &stat_directory);
     will_return(__wrap_f_file_stat, F_okay);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
 
     // Directory processing.
     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, 0);
     will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_d | f_directory_recurse_do_flag_directory_d);
 
-    // 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, macro_f_file_type_is_link(statistics.st_mode));
-    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);
 
@@ -165,29 +153,26 @@ void test__kt_remove__directory_no_args__one_empty_exists_link_not(void **state)
   {
     const f_string_t argv[] = { "mocked_main", target.string, "+" F_console_standard_short_verbose_s, 0 };
 
-    memset(&statistics, 0, sizeof(struct stat));
-    statistics.st_mode = F_file_mode_all_d | F_file_type_directory_d; // Should result in kt_remove_flag_operate_remove_d.
+    memset(&stat_directory, 0, sizeof(struct stat));
+    stat_directory.st_mode = F_file_mode_all_d | F_file_type_directory_d; // Should result in kt_remove_flag_operate_remove_d.
 
     // Pre-process target.
     will_return(__wrap_f_file_exists, F_true);
     will_return(__wrap_f_file_is, F_false); // Not a link, kt_remove_flag_operate_link_d is not set.
-    will_return(__wrap_f_file_stat, &statistics);
+    will_return(__wrap_f_file_stat, &stat_directory);
     will_return(__wrap_f_file_stat, F_okay);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
 
     // Directory processing.
     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, 0);
     will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_d | f_directory_recurse_do_flag_directory_d);
 
-    // 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, macro_f_file_type_is_link(statistics.st_mode));
-    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);
 
@@ -199,29 +184,26 @@ void test__kt_remove__directory_no_args__one_empty_exists_link_not(void **state)
   {
     const f_string_t argv[] = { "mocked_main", target.string, "+" F_console_standard_short_debug_s, 0 };
 
-    memset(&statistics, 0, sizeof(struct stat));
-    statistics.st_mode = F_file_mode_all_d | F_file_type_directory_d; // Should result in kt_remove_flag_operate_remove_d.
+    memset(&stat_directory, 0, sizeof(struct stat));
+    stat_directory.st_mode = F_file_mode_all_d | F_file_type_directory_d; // Should result in kt_remove_flag_operate_remove_d.
 
     // Pre-process target.
     will_return(__wrap_f_file_exists, F_true);
     will_return(__wrap_f_file_is, F_false); // Not a link, kt_remove_flag_operate_link_d is not set.
-    will_return(__wrap_f_file_stat, &statistics);
+    will_return(__wrap_f_file_stat, &stat_directory);
     will_return(__wrap_f_file_stat, F_okay);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
 
     // Directory processing.
     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, 0);
     will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_d | f_directory_recurse_do_flag_directory_d);
 
-    // 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, macro_f_file_type_is_link(statistics.st_mode));
-    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);
 
@@ -276,38 +258,35 @@ void test__kt_remove__directory_no_args__one_empty_not_exists_link(void **state)
 
   const f_string_static_t target = macro_f_string_static_t_initialize_1("to_remove", 0, 9);
 
-  struct stat statistics;
-  struct stat statistics_regular;
+  struct stat stat_directory;
+  struct stat stat_regular;
 
   {
     const f_string_t argv[] = { "mocked_main", target.string, "-" KT_REMOVE_short_empty_s, KT_REMOVE_not_s, 0 };
 
-    memset(&statistics, 0, sizeof(struct stat));
-    statistics.st_mode = F_file_mode_all_d | F_file_type_directory_d; // Should result in kt_remove_flag_operate_remove_d.
+    memset(&stat_directory, 0, sizeof(struct stat));
+    stat_directory.st_mode = F_file_mode_all_d | F_file_type_directory_d; // Should result in kt_remove_flag_operate_remove_d.
 
-    memset(&statistics_regular, 0, sizeof(struct stat));
-    statistics_regular.st_mode = F_file_mode_all_d | F_file_type_regular_d; // Should result in kt_remove_flag_operate_remove_d.
+    memset(&stat_regular, 0, sizeof(struct stat));
+    stat_regular.st_mode = F_file_mode_all_d | F_file_type_regular_d; // Should result in kt_remove_flag_operate_remove_d.
 
     // Pre-process target.
     will_return(__wrap_f_file_exists, F_true);
     will_return(__wrap_f_file_is, F_true); // A link, kt_remove_flag_operate_link_d is set.
-    will_return(__wrap_f_file_stat, &statistics);
+    will_return(__wrap_f_file_stat, &stat_directory);
     will_return(__wrap_f_file_stat, F_okay);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
 
     // Directory processing.
     will_return(__wrap_f_directory_empty, F_false); // kt_remove_flag_operate_empty_d is set.
     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, 0);
     will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_d | f_directory_recurse_do_flag_directory_d);
 
-    // 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_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_false);
-
     // 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);
 
@@ -319,32 +298,29 @@ void test__kt_remove__directory_no_args__one_empty_not_exists_link(void **state)
   {
     const f_string_t argv[] = { "mocked_main", target.string, "+" F_console_standard_short_verbose_s, "-" KT_REMOVE_short_empty_s, KT_REMOVE_not_s, 0 };
 
-    memset(&statistics, 0, sizeof(struct stat));
-    statistics.st_mode = F_file_mode_all_d | F_file_type_directory_d; // Should result in kt_remove_flag_operate_remove_d.
+    memset(&stat_directory, 0, sizeof(struct stat));
+    stat_directory.st_mode = F_file_mode_all_d | F_file_type_directory_d; // Should result in kt_remove_flag_operate_remove_d.
 
-    memset(&statistics_regular, 0, sizeof(struct stat));
-    statistics_regular.st_mode = F_file_mode_all_d | F_file_type_regular_d; // Should result in kt_remove_flag_operate_remove_d.
+    memset(&stat_regular, 0, sizeof(struct stat));
+    stat_regular.st_mode = F_file_mode_all_d | F_file_type_regular_d; // Should result in kt_remove_flag_operate_remove_d.
 
     // Pre-process target.
     will_return(__wrap_f_file_exists, F_true);
     will_return(__wrap_f_file_is, F_true); // A link, kt_remove_flag_operate_link_d is set.
-    will_return(__wrap_f_file_stat, &statistics);
+    will_return(__wrap_f_file_stat, &stat_directory);
     will_return(__wrap_f_file_stat, F_okay);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
 
     // Directory processing.
     will_return(__wrap_f_directory_empty, F_false); // kt_remove_flag_operate_empty_d is set.
     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, 0);
     will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_d | f_directory_recurse_do_flag_directory_d);
 
-    // 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_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_false);
-
     // 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);
 
@@ -356,32 +332,29 @@ void test__kt_remove__directory_no_args__one_empty_not_exists_link(void **state)
   {
     const f_string_t argv[] = { "mocked_main", target.string, "+" F_console_standard_short_debug_s, "-" KT_REMOVE_short_empty_s, KT_REMOVE_not_s, 0 };
 
-    memset(&statistics, 0, sizeof(struct stat));
-    statistics.st_mode = F_file_mode_all_d | F_file_type_directory_d; // Should result in kt_remove_flag_operate_remove_d.
+    memset(&stat_directory, 0, sizeof(struct stat));
+    stat_directory.st_mode = F_file_mode_all_d | F_file_type_directory_d; // Should result in kt_remove_flag_operate_remove_d.
 
-    memset(&statistics_regular, 0, sizeof(struct stat));
-    statistics_regular.st_mode = F_file_mode_all_d | F_file_type_regular_d; // Should result in kt_remove_flag_operate_remove_d.
+    memset(&stat_regular, 0, sizeof(struct stat));
+    stat_regular.st_mode = F_file_mode_all_d | F_file_type_regular_d; // Should result in kt_remove_flag_operate_remove_d.
 
     // Pre-process target.
     will_return(__wrap_f_file_exists, F_true);
     will_return(__wrap_f_file_is, F_true); // A link, kt_remove_flag_operate_link_d is set.
-    will_return(__wrap_f_file_stat, &statistics);
+    will_return(__wrap_f_file_stat, &stat_directory);
     will_return(__wrap_f_file_stat, F_okay);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
 
     // Directory processing.
     will_return(__wrap_f_directory_empty, F_false); // kt_remove_flag_operate_empty_d is set.
     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, 0);
     will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_d | f_directory_recurse_do_flag_directory_d);
 
-    // 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_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_false);
-
     // 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);
 
@@ -399,49 +372,63 @@ void test__kt_remove__directory_no_args__one_empty_not_exists_link_not(void **st
   const f_string_static_t target = 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;
+  struct stat stat_directory;
+  struct stat stat_regular;
 
   {
     const f_string_t argv[] = { "mocked_main", target.string, "-" KT_REMOVE_short_empty_s, KT_REMOVE_not_s, 0 };
 
-    memset(&statistics, 0, sizeof(struct stat));
-    statistics.st_mode = F_file_mode_all_d | F_file_type_directory_d; // Should result in kt_remove_flag_operate_remove_d.
+    memset(&stat_directory, 0, sizeof(struct stat));
+    stat_directory.st_mode = F_file_mode_all_d | F_file_type_directory_d; // Should result in kt_remove_flag_operate_remove_d.
 
-    memset(&statistics_regular, 0, sizeof(struct stat));
-    statistics_regular.st_mode = F_file_mode_all_d | F_file_type_regular_d; // Should result in kt_remove_flag_operate_remove_d.
+    memset(&stat_regular, 0, sizeof(struct stat));
+    stat_regular.st_mode = F_file_mode_all_d | F_file_type_regular_d; // Should result in kt_remove_flag_operate_remove_d.
 
     // Pre-process target.
     will_return(__wrap_f_file_exists, F_true);
     will_return(__wrap_f_file_is, F_false); // Not a link, kt_remove_flag_operate_link_d is not set.
-    will_return(__wrap_f_file_stat, &statistics);
+    will_return(__wrap_f_file_stat, &stat_directory);
     will_return(__wrap_f_file_stat, F_okay);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
 
-    // Directory processing.
+    // Top directory processing.
     will_return(__wrap_f_directory_empty, F_false); // kt_remove_flag_operate_empty_d is set.
-    will_return(__wrap_fl_directory_do, 2);
+    will_return(__wrap_fl_directory_do, 4);
+
+    // Begin top path.
+    will_return(__wrap_fl_directory_do, &target);
+    will_return(__wrap_fl_directory_do, &target);
+    will_return(__wrap_fl_directory_do, 0);
+    will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_before_d | f_directory_recurse_do_flag_directory_d);
+
+    // Child path.
     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_d | f_directory_recurse_do_flag_regular_d);
+    will_return(__wrap_fl_directory_do, 1);
+    will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_before_d | f_directory_recurse_do_flag_regular_d);
 
     will_return(__wrap_f_file_exists, F_true);
     will_return(__wrap_f_file_is, F_false); // Not a link, kt_remove_flag_operate_link_d is not set.
-    will_return(__wrap_f_file_stat, &statistics_regular);
+    will_return(__wrap_f_file_stat, &stat_regular);
     will_return(__wrap_f_file_stat, F_okay);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
     will_return(__wrap_f_file_remove, F_okay);
 
-    // Parent directory.
+    will_return(__wrap_fl_directory_do, &child);
+    will_return(__wrap_fl_directory_do, &child);
+    will_return(__wrap_fl_directory_do, 1);
+    will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_d | f_directory_recurse_do_flag_regular_d);
+
+    // End top path.
     will_return(__wrap_fl_directory_do, &target);
     will_return(__wrap_fl_directory_do, &target);
+    will_return(__wrap_fl_directory_do, 0);
     will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_d | f_directory_recurse_do_flag_directory_d);
 
-    // 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_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_false);
-
     // 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);
 
@@ -453,43 +440,57 @@ void test__kt_remove__directory_no_args__one_empty_not_exists_link_not(void **st
   {
     const f_string_t argv[] = { "mocked_main", target.string, "+" F_console_standard_short_verbose_s, "-" KT_REMOVE_short_empty_s, KT_REMOVE_not_s, 0 };
 
-    memset(&statistics, 0, sizeof(struct stat));
-    statistics.st_mode = F_file_mode_all_d | F_file_type_directory_d; // Should result in kt_remove_flag_operate_remove_d.
+    memset(&stat_directory, 0, sizeof(struct stat));
+    stat_directory.st_mode = F_file_mode_all_d | F_file_type_directory_d; // Should result in kt_remove_flag_operate_remove_d.
 
-    memset(&statistics_regular, 0, sizeof(struct stat));
-    statistics_regular.st_mode = F_file_mode_all_d | F_file_type_regular_d; // Should result in kt_remove_flag_operate_remove_d.
+    memset(&stat_regular, 0, sizeof(struct stat));
+    stat_regular.st_mode = F_file_mode_all_d | F_file_type_regular_d; // Should result in kt_remove_flag_operate_remove_d.
 
     // Pre-process target.
     will_return(__wrap_f_file_exists, F_true);
     will_return(__wrap_f_file_is, F_false); // Not a link, kt_remove_flag_operate_link_d is not set.
-    will_return(__wrap_f_file_stat, &statistics);
+    will_return(__wrap_f_file_stat, &stat_directory);
     will_return(__wrap_f_file_stat, F_okay);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
 
-    // Directory processing.
+    // Top directory processing.
     will_return(__wrap_f_directory_empty, F_false); // kt_remove_flag_operate_empty_d is set.
-    will_return(__wrap_fl_directory_do, 2);
+    will_return(__wrap_fl_directory_do, 4);
+
+    // Begin top path.
+    will_return(__wrap_fl_directory_do, &target);
+    will_return(__wrap_fl_directory_do, &target);
+    will_return(__wrap_fl_directory_do, 0);
+    will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_before_d | f_directory_recurse_do_flag_directory_d);
+
+    // Child path.
     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_d | f_directory_recurse_do_flag_regular_d);
+    will_return(__wrap_fl_directory_do, 1);
+    will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_before_d | f_directory_recurse_do_flag_regular_d);
 
     will_return(__wrap_f_file_exists, F_true);
     will_return(__wrap_f_file_is, F_false); // Not a link, kt_remove_flag_operate_link_d is not set.
-    will_return(__wrap_f_file_stat, &statistics_regular);
+    will_return(__wrap_f_file_stat, &stat_regular);
     will_return(__wrap_f_file_stat, F_okay);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
     will_return(__wrap_f_file_remove, F_okay);
 
-    // Parent directory.
+    will_return(__wrap_fl_directory_do, &child);
+    will_return(__wrap_fl_directory_do, &child);
+    will_return(__wrap_fl_directory_do, 1);
+    will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_d | f_directory_recurse_do_flag_regular_d);
+
+    // End top path.
     will_return(__wrap_fl_directory_do, &target);
     will_return(__wrap_fl_directory_do, &target);
+    will_return(__wrap_fl_directory_do, 0);
     will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_d | f_directory_recurse_do_flag_directory_d);
 
-    // 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_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_false);
-
     // 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);
 
@@ -501,43 +502,57 @@ void test__kt_remove__directory_no_args__one_empty_not_exists_link_not(void **st
   {
     const f_string_t argv[] = { "mocked_main", target.string, "+" F_console_standard_short_debug_s, "-" KT_REMOVE_short_empty_s, KT_REMOVE_not_s, 0 };
 
-    memset(&statistics, 0, sizeof(struct stat));
-    statistics.st_mode = F_file_mode_all_d | F_file_type_directory_d; // Should result in kt_remove_flag_operate_remove_d.
+    memset(&stat_directory, 0, sizeof(struct stat));
+    stat_directory.st_mode = F_file_mode_all_d | F_file_type_directory_d; // Should result in kt_remove_flag_operate_remove_d.
 
-    memset(&statistics_regular, 0, sizeof(struct stat));
-    statistics_regular.st_mode = F_file_mode_all_d | F_file_type_regular_d; // Should result in kt_remove_flag_operate_remove_d.
+    memset(&stat_regular, 0, sizeof(struct stat));
+    stat_regular.st_mode = F_file_mode_all_d | F_file_type_regular_d; // Should result in kt_remove_flag_operate_remove_d.
 
     // Pre-process target.
     will_return(__wrap_f_file_exists, F_true);
     will_return(__wrap_f_file_is, F_false); // Not a link, kt_remove_flag_operate_link_d is not set.
-    will_return(__wrap_f_file_stat, &statistics);
+    will_return(__wrap_f_file_stat, &stat_directory);
     will_return(__wrap_f_file_stat, F_okay);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
 
-    // Directory processing.
+    // Top directory processing.
     will_return(__wrap_f_directory_empty, F_false); // kt_remove_flag_operate_empty_d is set.
-    will_return(__wrap_fl_directory_do, 2);
+    will_return(__wrap_fl_directory_do, 4);
+
+    // Begin top path.
+    will_return(__wrap_fl_directory_do, &target);
+    will_return(__wrap_fl_directory_do, &target);
+    will_return(__wrap_fl_directory_do, 0);
+    will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_before_d | f_directory_recurse_do_flag_directory_d);
+
+    // Child path.
     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_d | f_directory_recurse_do_flag_regular_d);
+    will_return(__wrap_fl_directory_do, 1);
+    will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_before_d | f_directory_recurse_do_flag_regular_d);
 
     will_return(__wrap_f_file_exists, F_true);
     will_return(__wrap_f_file_is, F_false); // Not a link, kt_remove_flag_operate_link_d is not set.
-    will_return(__wrap_f_file_stat, &statistics_regular);
+    will_return(__wrap_f_file_stat, &stat_regular);
     will_return(__wrap_f_file_stat, F_okay);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
     will_return(__wrap_f_file_remove, F_okay);
 
-    // Parent directory.
+    will_return(__wrap_fl_directory_do, &child);
+    will_return(__wrap_fl_directory_do, &child);
+    will_return(__wrap_fl_directory_do, 1);
+    will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_d | f_directory_recurse_do_flag_regular_d);
+
+    // End top path.
     will_return(__wrap_fl_directory_do, &target);
     will_return(__wrap_fl_directory_do, &target);
+    will_return(__wrap_fl_directory_do, 0);
     will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_d | f_directory_recurse_do_flag_directory_d);
 
-    // 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_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_false);
-
     // 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);
 
@@ -555,16 +570,17 @@ void test__kt_remove__directory_no_args__two_empty_exists_and_not(void **state)
   const f_string_static_t target = macro_f_string_static_t_initialize_1("to_remove", 0, 9);
   const f_string_static_t target_also = macro_f_string_static_t_initialize_1("also/remove", 0, 11);
 
-  struct stat statistics;
+  struct stat stat_directory;
 
   {
     const f_string_t argv[] = { "mocked_main", target.string, target_also.string, 0 };
 
-    memset(&statistics, 0, sizeof(struct stat));
-    statistics.st_mode = F_file_mode_all_d | F_file_type_directory_d; // Should result in kt_remove_flag_operate_remove_d.
+    memset(&stat_directory, 0, sizeof(struct stat));
+    stat_directory.st_mode = F_file_mode_all_d | F_file_type_directory_d; // Should result in kt_remove_flag_operate_remove_d.
 
     // Pre-process target 1.
     will_return(__wrap_f_file_exists, F_false);
+    will_return(__wrap_f_file_exists, F_false);
 
     const int result = kt_main_test__remove(3, argv, 0);
 
@@ -574,11 +590,12 @@ void test__kt_remove__directory_no_args__two_empty_exists_and_not(void **state)
   {
     const f_string_t argv[] = { "mocked_main", target.string, target_also.string, "+" F_console_standard_short_verbose_s, 0 };
 
-    memset(&statistics, 0, sizeof(struct stat));
-    statistics.st_mode = F_file_mode_all_d | F_file_type_directory_d; // Should result in kt_remove_flag_operate_remove_d.
+    memset(&stat_directory, 0, sizeof(struct stat));
+    stat_directory.st_mode = F_file_mode_all_d | F_file_type_directory_d; // Should result in kt_remove_flag_operate_remove_d.
 
     // Pre-process target 1.
     will_return(__wrap_f_file_exists, F_false);
+    will_return(__wrap_f_file_exists, F_false);
 
     const int result = kt_main_test__remove(4, argv, 0);
 
@@ -588,11 +605,12 @@ void test__kt_remove__directory_no_args__two_empty_exists_and_not(void **state)
   {
     const f_string_t argv[] = { "mocked_main", target.string, target_also.string, "+" F_console_standard_short_debug_s, 0 };
 
-    memset(&statistics, 0, sizeof(struct stat));
-    statistics.st_mode = F_file_mode_all_d | F_file_type_directory_d; // Should result in kt_remove_flag_operate_remove_d.
+    memset(&stat_directory, 0, sizeof(struct stat));
+    stat_directory.st_mode = F_file_mode_all_d | F_file_type_directory_d; // Should result in kt_remove_flag_operate_remove_d.
 
     // Pre-process target 1.
     will_return(__wrap_f_file_exists, F_false);
+    will_return(__wrap_f_file_exists, F_false);
 
     const int result = kt_main_test__remove(4, argv, 0);
 
@@ -608,57 +626,51 @@ void test__kt_remove__directory_no_args__two_empty_exists_link(void **state) {
   const f_string_static_t target = macro_f_string_static_t_initialize_1("to_remove", 0, 9);
   const f_string_static_t target_also = macro_f_string_static_t_initialize_1("also/remove", 0, 11);
 
-  struct stat statistics;
+  struct stat stat_directory;
 
   {
     const f_string_t argv[] = { "mocked_main", target.string, target_also.string, 0 };
 
-    memset(&statistics, 0, sizeof(struct stat));
-    statistics.st_mode = F_file_mode_all_d | F_file_type_directory_d; // Should result in kt_remove_flag_operate_remove_d.
+    memset(&stat_directory, 0, sizeof(struct stat));
+    stat_directory.st_mode = F_file_mode_all_d | F_file_type_directory_d; // Should result in kt_remove_flag_operate_remove_d.
 
     // Pre-process target 1.
     will_return(__wrap_f_file_exists, F_true);
     will_return(__wrap_f_file_is, F_true); // A link, kt_remove_flag_operate_link_d is set.
-    will_return(__wrap_f_file_stat, &statistics);
+    will_return(__wrap_f_file_stat, &stat_directory);
     will_return(__wrap_f_file_stat, F_okay);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
 
     // Directory processing.
     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, 0);
     will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_d | f_directory_recurse_do_flag_directory_d);
 
-    // 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);
-    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);
 
     // Pre-process target 2.
     will_return(__wrap_f_file_exists, F_true);
     will_return(__wrap_f_file_is, F_true); // A link, kt_remove_flag_operate_link_d is set.
-    will_return(__wrap_f_file_stat, &statistics);
+    will_return(__wrap_f_file_stat, &stat_directory);
     will_return(__wrap_f_file_stat, F_okay);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
 
     // Directory processing.
     will_return(__wrap_f_directory_empty, F_true);
     will_return(__wrap_fl_directory_do, 1);
     will_return(__wrap_fl_directory_do, &target_also);
     will_return(__wrap_fl_directory_do, &target_also);
+    will_return(__wrap_fl_directory_do, 0);
     will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_d | f_directory_recurse_do_flag_directory_d);
 
-    // 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);
-    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);
 
@@ -670,52 +682,46 @@ void test__kt_remove__directory_no_args__two_empty_exists_link(void **state) {
   {
     const f_string_t argv[] = { "mocked_main", target.string, target_also.string, "+" F_console_standard_short_verbose_s, 0 };
 
-    memset(&statistics, 0, sizeof(struct stat));
-    statistics.st_mode = F_file_mode_all_d | F_file_type_directory_d; // Should result in kt_remove_flag_operate_remove_d.
+    memset(&stat_directory, 0, sizeof(struct stat));
+    stat_directory.st_mode = F_file_mode_all_d | F_file_type_directory_d; // Should result in kt_remove_flag_operate_remove_d.
 
     // Pre-process target 1.
     will_return(__wrap_f_file_exists, F_true);
     will_return(__wrap_f_file_is, F_true); // A link, kt_remove_flag_operate_link_d is set.
-    will_return(__wrap_f_file_stat, &statistics);
+    will_return(__wrap_f_file_stat, &stat_directory);
     will_return(__wrap_f_file_stat, F_okay);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
 
     // Directory processing.
     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, 0);
     will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_d | f_directory_recurse_do_flag_directory_d);
 
-    // 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);
-    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);
 
     // Pre-process target 2.
     will_return(__wrap_f_file_exists, F_true);
     will_return(__wrap_f_file_is, F_true); // A link, kt_remove_flag_operate_link_d is set.
-    will_return(__wrap_f_file_stat, &statistics);
+    will_return(__wrap_f_file_stat, &stat_directory);
     will_return(__wrap_f_file_stat, F_okay);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
 
     // Directory processing.
     will_return(__wrap_f_directory_empty, F_true);
     will_return(__wrap_fl_directory_do, 1);
     will_return(__wrap_fl_directory_do, &target_also);
     will_return(__wrap_fl_directory_do, &target_also);
+    will_return(__wrap_fl_directory_do, 0);
     will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_d | f_directory_recurse_do_flag_directory_d);
 
-    // 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);
-    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);
 
@@ -727,52 +733,46 @@ void test__kt_remove__directory_no_args__two_empty_exists_link(void **state) {
   {
     const f_string_t argv[] = { "mocked_main", target.string, target_also.string, "+" F_console_standard_short_debug_s, 0 };
 
-    memset(&statistics, 0, sizeof(struct stat));
-    statistics.st_mode = F_file_mode_all_d | F_file_type_directory_d; // Should result in kt_remove_flag_operate_remove_d.
+    memset(&stat_directory, 0, sizeof(struct stat));
+    stat_directory.st_mode = F_file_mode_all_d | F_file_type_directory_d; // Should result in kt_remove_flag_operate_remove_d.
 
     // Pre-process target 1.
     will_return(__wrap_f_file_exists, F_true);
     will_return(__wrap_f_file_is, F_true); // A link, kt_remove_flag_operate_link_d is set.
-    will_return(__wrap_f_file_stat, &statistics);
+    will_return(__wrap_f_file_stat, &stat_directory);
     will_return(__wrap_f_file_stat, F_okay);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
 
     // Directory processing.
     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, 0);
     will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_d | f_directory_recurse_do_flag_directory_d);
 
-    // 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);
-    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);
 
     // Pre-process target 2.
     will_return(__wrap_f_file_exists, F_true);
     will_return(__wrap_f_file_is, F_true); // A link, kt_remove_flag_operate_link_d is set.
-    will_return(__wrap_f_file_stat, &statistics);
+    will_return(__wrap_f_file_stat, &stat_directory);
     will_return(__wrap_f_file_stat, F_okay);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
 
     // Directory processing.
     will_return(__wrap_f_directory_empty, F_true);
     will_return(__wrap_fl_directory_do, 1);
     will_return(__wrap_fl_directory_do, &target_also);
     will_return(__wrap_fl_directory_do, &target_also);
+    will_return(__wrap_fl_directory_do, 0);
     will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_d | f_directory_recurse_do_flag_directory_d);
 
-    // 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);
-    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);
 
@@ -790,57 +790,51 @@ void test__kt_remove__directory_no_args__two_empty_exists_link_not(void **state)
   const f_string_static_t target = macro_f_string_static_t_initialize_1("to_remove", 0, 9);
   const f_string_static_t target_also = macro_f_string_static_t_initialize_1("also/remove", 0, 11);
 
-  struct stat statistics;
+  struct stat stat_directory;
 
   {
     const f_string_t argv[] = { "mocked_main", target.string, target_also.string, 0 };
 
-    memset(&statistics, 0, sizeof(struct stat));
-    statistics.st_mode = F_file_mode_all_d | F_file_type_directory_d; // Should result in kt_remove_flag_operate_remove_d.
+    memset(&stat_directory, 0, sizeof(struct stat));
+    stat_directory.st_mode = F_file_mode_all_d | F_file_type_directory_d; // Should result in kt_remove_flag_operate_remove_d.
 
     // Pre-process target 1.
     will_return(__wrap_f_file_exists, F_true);
     will_return(__wrap_f_file_is, F_false); // Not a link, kt_remove_flag_operate_link_d is not set.
-    will_return(__wrap_f_file_stat, &statistics);
+    will_return(__wrap_f_file_stat, &stat_directory);
     will_return(__wrap_f_file_stat, F_okay);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
 
     // Directory processing.
     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, 0);
     will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_d | f_directory_recurse_do_flag_directory_d);
 
-    // 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);
-    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);
 
     // Pre-process target 2.
     will_return(__wrap_f_file_exists, F_true);
     will_return(__wrap_f_file_is, F_true); // A link, kt_remove_flag_operate_link_d is set.
-    will_return(__wrap_f_file_stat, &statistics);
+    will_return(__wrap_f_file_stat, &stat_directory);
     will_return(__wrap_f_file_stat, F_okay);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
 
     // Directory processing.
     will_return(__wrap_f_directory_empty, F_true);
     will_return(__wrap_fl_directory_do, 1);
     will_return(__wrap_fl_directory_do, &target_also);
     will_return(__wrap_fl_directory_do, &target_also);
+    will_return(__wrap_fl_directory_do, 0);
     will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_d | f_directory_recurse_do_flag_directory_d);
 
-    // 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);
-    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);
 
@@ -852,52 +846,46 @@ void test__kt_remove__directory_no_args__two_empty_exists_link_not(void **state)
   {
     const f_string_t argv[] = { "mocked_main", target.string, target_also.string, "+" F_console_standard_short_verbose_s, 0 };
 
-    memset(&statistics, 0, sizeof(struct stat));
-    statistics.st_mode = F_file_mode_all_d | F_file_type_directory_d; // Should result in kt_remove_flag_operate_remove_d.
+    memset(&stat_directory, 0, sizeof(struct stat));
+    stat_directory.st_mode = F_file_mode_all_d | F_file_type_directory_d; // Should result in kt_remove_flag_operate_remove_d.
 
     // Pre-process target 1.
     will_return(__wrap_f_file_exists, F_true);
     will_return(__wrap_f_file_is, F_false); // Not a link, kt_remove_flag_operate_link_d is not set.
-    will_return(__wrap_f_file_stat, &statistics);
+    will_return(__wrap_f_file_stat, &stat_directory);
     will_return(__wrap_f_file_stat, F_okay);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
 
     // Directory processing.
     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, 0);
     will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_d | f_directory_recurse_do_flag_directory_d);
 
-    // 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);
-    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);
 
     // Pre-process target 2.
     will_return(__wrap_f_file_exists, F_true);
     will_return(__wrap_f_file_is, F_true); // A link, kt_remove_flag_operate_link_d is set.
-    will_return(__wrap_f_file_stat, &statistics);
+    will_return(__wrap_f_file_stat, &stat_directory);
     will_return(__wrap_f_file_stat, F_okay);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
 
     // Directory processing.
     will_return(__wrap_f_directory_empty, F_true);
     will_return(__wrap_fl_directory_do, 1);
     will_return(__wrap_fl_directory_do, &target_also);
     will_return(__wrap_fl_directory_do, &target_also);
+    will_return(__wrap_fl_directory_do, 0);
     will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_d | f_directory_recurse_do_flag_directory_d);
 
-    // 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);
-    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);
 
@@ -909,52 +897,46 @@ void test__kt_remove__directory_no_args__two_empty_exists_link_not(void **state)
   {
     const f_string_t argv[] = { "mocked_main", target.string, target_also.string, "+" F_console_standard_short_debug_s, 0 };
 
-    memset(&statistics, 0, sizeof(struct stat));
-    statistics.st_mode = F_file_mode_all_d | F_file_type_directory_d; // Should result in kt_remove_flag_operate_remove_d.
+    memset(&stat_directory, 0, sizeof(struct stat));
+    stat_directory.st_mode = F_file_mode_all_d | F_file_type_directory_d; // Should result in kt_remove_flag_operate_remove_d.
 
     // Pre-process target 1.
     will_return(__wrap_f_file_exists, F_true);
     will_return(__wrap_f_file_is, F_false); // Not a link, kt_remove_flag_operate_link_d is not set.
-    will_return(__wrap_f_file_stat, &statistics);
+    will_return(__wrap_f_file_stat, &stat_directory);
     will_return(__wrap_f_file_stat, F_okay);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
 
     // Directory processing.
     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, 0);
     will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_d | f_directory_recurse_do_flag_directory_d);
 
-    // 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);
-    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);
 
     // Pre-process target 2.
     will_return(__wrap_f_file_exists, F_true);
     will_return(__wrap_f_file_is, F_true); // A link, kt_remove_flag_operate_link_d is set.
-    will_return(__wrap_f_file_stat, &statistics);
+    will_return(__wrap_f_file_stat, &stat_directory);
     will_return(__wrap_f_file_stat, F_okay);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
 
     // Directory processing.
     will_return(__wrap_f_directory_empty, F_true);
     will_return(__wrap_fl_directory_do, 1);
     will_return(__wrap_fl_directory_do, &target_also);
     will_return(__wrap_fl_directory_do, &target_also);
+    will_return(__wrap_fl_directory_do, 0);
     will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_d | f_directory_recurse_do_flag_directory_d);
 
-    // 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);
-    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);
 
@@ -976,6 +958,7 @@ void test__kt_remove__directory_no_args__two_empty_exists_not(void **state) {
     const f_string_t argv[] = { "mocked_main", target.string, target_also.string, 0 };
 
     will_return(__wrap_f_file_exists, F_false);
+    will_return(__wrap_f_file_exists, F_false);
 
     const int result = kt_main_test__remove(3, argv, 0);
 
@@ -986,6 +969,7 @@ void test__kt_remove__directory_no_args__two_empty_exists_not(void **state) {
     const f_string_t argv[] = { "mocked_main", target.string, target_also.string, "+" F_console_standard_short_verbose_s, 0 };
 
     will_return(__wrap_f_file_exists, F_false);
+    will_return(__wrap_f_file_exists, F_false);
 
     const int result = kt_main_test__remove(4, argv, 0);
 
@@ -996,6 +980,7 @@ void test__kt_remove__directory_no_args__two_empty_exists_not(void **state) {
     const f_string_t argv[] = { "mocked_main", target.string, target_also.string, "+" F_console_standard_short_debug_s, 0 };
 
     will_return(__wrap_f_file_exists, F_false);
+    will_return(__wrap_f_file_exists, F_false);
 
     const int result = kt_main_test__remove(4, argv, 0);
 
index 7968a0d8f1c2a353c3396afa340f3b3b7e88e4f9..8b9fb2e6df1fd88febb2dca3cd4d01a52d54bf18 100644 (file)
@@ -32,33 +32,47 @@ void test__kt_remove__directory_recurse_simple__one_child_one_exists_link(void *
     will_return(__wrap_f_file_is, F_true); // A link, kt_remove_flag_operate_link_d is set.
     will_return(__wrap_f_file_stat, &stat_directory);
     will_return(__wrap_f_file_stat, F_okay);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
 
-    // Target Directory pre-processing, begin, perform directory listing action.
-    will_return(__wrap_f_directory_empty, F_false);
-    will_return(__wrap_fl_directory_do, 2);
+    // Top directory processing.
+    will_return(__wrap_f_directory_empty, F_false); // kt_remove_flag_operate_empty_d is set.
+    will_return(__wrap_fl_directory_do, 4);
+
+    // Begin top path.
+    will_return(__wrap_fl_directory_do, &target);
+    will_return(__wrap_fl_directory_do, &target);
+    will_return(__wrap_fl_directory_do, 0);
+    will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_before_d | f_directory_recurse_do_flag_directory_d);
 
-    // The first child pre-processing.
+    // Child path.
     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_d | f_directory_recurse_do_flag_regular_d);
+    will_return(__wrap_fl_directory_do, 1);
+    will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_before_d | f_directory_recurse_do_flag_regular_d);
+
     will_return(__wrap_f_file_exists, F_true);
     will_return(__wrap_f_file_is, F_false); // Not a link, kt_remove_flag_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_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
     will_return(__wrap_f_file_remove, F_okay);
 
-    // The parent.
+    will_return(__wrap_fl_directory_do, &child_1);
+    will_return(__wrap_fl_directory_do, &child_1);
+    will_return(__wrap_fl_directory_do, 1);
+    will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_d | f_directory_recurse_do_flag_regular_d);
+
+    // End top path.
     will_return(__wrap_fl_directory_do, &target);
     will_return(__wrap_fl_directory_do, &target);
+    will_return(__wrap_fl_directory_do, 0);
     will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_d | f_directory_recurse_do_flag_directory_d);
 
-    // 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);
-    will_return(__wrap_f_file_stat, &stat_directory);
-    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);
 
     const int result = kt_main_test__remove(3, argv, 0);
@@ -92,33 +106,47 @@ 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_operate_link_d is not set.
     will_return(__wrap_f_file_stat, &stat_directory);
     will_return(__wrap_f_file_stat, F_okay);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
 
     // Target Directory pre-processing, begin, perform directory listing action.
     will_return(__wrap_f_directory_empty, F_false);
-    will_return(__wrap_fl_directory_do, 2);
+    will_return(__wrap_fl_directory_do, 4);
+
+    // Begin top path.
+    will_return(__wrap_fl_directory_do, &target);
+    will_return(__wrap_fl_directory_do, &target);
+    will_return(__wrap_fl_directory_do, 0);
+    will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_before_d | f_directory_recurse_do_flag_directory_d);
 
-    // The first child pre-processing.
+    // Child path.
     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_d | f_directory_recurse_do_flag_regular_d);
+    will_return(__wrap_fl_directory_do, 1);
+    will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_before_d | f_directory_recurse_do_flag_regular_d);
+
     will_return(__wrap_f_file_exists, F_true);
     will_return(__wrap_f_file_is, F_false); // Not a link, kt_remove_flag_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_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
     will_return(__wrap_f_file_remove, F_okay);
 
-    // The parent.
+    will_return(__wrap_fl_directory_do, &child_1);
+    will_return(__wrap_fl_directory_do, &child_1);
+    will_return(__wrap_fl_directory_do, 1);
+    will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_d | f_directory_recurse_do_flag_regular_d);
+
+    // End top path.
     will_return(__wrap_fl_directory_do, &target);
     will_return(__wrap_fl_directory_do, &target);
+    will_return(__wrap_fl_directory_do, 0);
     will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_d | f_directory_recurse_do_flag_directory_d);
 
-    // 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);
-    will_return(__wrap_f_file_stat, &stat_directory);
-    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);
 
     const int result = kt_main_test__remove(3, argv, 0);
@@ -148,48 +176,72 @@ void test__kt_remove__directory_recurse_simple__one_child_two_exists_link(void *
     stat_directory.st_mode = F_file_mode_all_d | F_file_type_directory_d;
     stat_regular.st_mode = F_file_mode_all_d | F_file_type_regular_d;
 
-    // Pre-process file.
+    // Pre-process target.
     will_return(__wrap_f_file_exists, F_true);
     will_return(__wrap_f_file_is, F_true); // A link, kt_remove_flag_operate_link_d is set.
     will_return(__wrap_f_file_stat, &stat_directory);
     will_return(__wrap_f_file_stat, F_okay);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
 
-    // Target Directory pre-processing, begin, perform directory listing action.
-    will_return(__wrap_f_directory_empty, F_false);
-    will_return(__wrap_fl_directory_do, 3);
+    // Top directory processing.
+    will_return(__wrap_f_directory_empty, F_false); // kt_remove_flag_operate_empty_d is set.
+    will_return(__wrap_fl_directory_do, 6);
 
-    // The first child processing.
+    // Begin top path.
+    will_return(__wrap_fl_directory_do, &target);
+    will_return(__wrap_fl_directory_do, &target);
+    will_return(__wrap_fl_directory_do, 0);
+    will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_before_d | f_directory_recurse_do_flag_directory_d);
+
+    // Child 1 path.
     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_d | f_directory_recurse_do_flag_regular_d);
+    will_return(__wrap_fl_directory_do, 1);
+    will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_before_d | f_directory_recurse_do_flag_regular_d);
+
     will_return(__wrap_f_file_exists, F_true);
     will_return(__wrap_f_file_is, F_false); // Not a link, kt_remove_flag_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_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
     will_return(__wrap_f_file_remove, F_okay);
 
-    // The second child processing.
+    will_return(__wrap_fl_directory_do, &child_1);
+    will_return(__wrap_fl_directory_do, &child_1);
+    will_return(__wrap_fl_directory_do, 1);
+    will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_d | f_directory_recurse_do_flag_regular_d);
+
+    // Child 2 path.
     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_d | f_directory_recurse_do_flag_regular_d);
+    will_return(__wrap_fl_directory_do, 1);
+    will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_before_d | f_directory_recurse_do_flag_regular_d);
+
     will_return(__wrap_f_file_exists, F_true);
     will_return(__wrap_f_file_is, F_true); // A link, kt_remove_flag_operate_link_d is set.
     will_return(__wrap_f_file_stat, &stat_regular);
     will_return(__wrap_f_file_stat, F_okay);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
     will_return(__wrap_f_file_remove, F_okay);
 
-    // The parent.
+    will_return(__wrap_fl_directory_do, &child_2);
+    will_return(__wrap_fl_directory_do, &child_2);
+    will_return(__wrap_fl_directory_do, 1);
+    will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_d | f_directory_recurse_do_flag_regular_d);
+
+    // End top path.
     will_return(__wrap_fl_directory_do, &target);
     will_return(__wrap_fl_directory_do, &target);
+    will_return(__wrap_fl_directory_do, 0);
     will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_d | f_directory_recurse_do_flag_directory_d);
 
-    // 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);
-    will_return(__wrap_f_file_stat, &stat_directory);
-    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);
 
     const int result = kt_main_test__remove(3, argv, 0);
@@ -219,48 +271,72 @@ void test__kt_remove__directory_recurse_simple__one_child_two_exists_link_not(vo
     stat_directory.st_mode = F_file_mode_all_d | F_file_type_directory_d;
     stat_regular.st_mode = F_file_mode_all_d | F_file_type_regular_d;
 
-    // Pre-process file.
+    // Pre-process target.
     will_return(__wrap_f_file_exists, F_true);
     will_return(__wrap_f_file_is, F_false); // Not a link, kt_remove_flag_operate_link_d is not set.
     will_return(__wrap_f_file_stat, &stat_directory);
     will_return(__wrap_f_file_stat, F_okay);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
 
-    // Target Directory pre-processing, begin, perform directory listing action.
-    will_return(__wrap_f_directory_empty, F_false);
-    will_return(__wrap_fl_directory_do, 3);
+    // Top directory processing.
+    will_return(__wrap_f_directory_empty, F_false); // kt_remove_flag_operate_empty_d is set.
+    will_return(__wrap_fl_directory_do, 6);
+
+    // Begin top path.
+    will_return(__wrap_fl_directory_do, &target);
+    will_return(__wrap_fl_directory_do, &target);
+    will_return(__wrap_fl_directory_do, 0);
+    will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_before_d | f_directory_recurse_do_flag_directory_d);
 
-    // The first child processing.
+    // Child 1 path.
     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_d | f_directory_recurse_do_flag_regular_d);
+    will_return(__wrap_fl_directory_do, 1);
+    will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_before_d | f_directory_recurse_do_flag_regular_d);
+
     will_return(__wrap_f_file_exists, F_true);
     will_return(__wrap_f_file_is, F_false); // Not a link, kt_remove_flag_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_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
     will_return(__wrap_f_file_remove, F_okay);
 
-    // The second child processing.
+    will_return(__wrap_fl_directory_do, &child_1);
+    will_return(__wrap_fl_directory_do, &child_1);
+    will_return(__wrap_fl_directory_do, 1);
+    will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_d | f_directory_recurse_do_flag_regular_d);
+
+    // Child 2 path.
     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_d | f_directory_recurse_do_flag_regular_d);
+    will_return(__wrap_fl_directory_do, 1);
+    will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_before_d | f_directory_recurse_do_flag_regular_d);
+
     will_return(__wrap_f_file_exists, F_true);
     will_return(__wrap_f_file_is, F_true); // A link, kt_remove_flag_operate_link_d is set.
     will_return(__wrap_f_file_stat, &stat_regular);
     will_return(__wrap_f_file_stat, F_okay);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
     will_return(__wrap_f_file_remove, F_okay);
 
-    // The parent.
+    will_return(__wrap_fl_directory_do, &child_2);
+    will_return(__wrap_fl_directory_do, &child_2);
+    will_return(__wrap_fl_directory_do, 1);
+    will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_d | f_directory_recurse_do_flag_regular_d);
+
+    // End top path.
     will_return(__wrap_fl_directory_do, &target);
     will_return(__wrap_fl_directory_do, &target);
+    will_return(__wrap_fl_directory_do, 0);
     will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_d | f_directory_recurse_do_flag_directory_d);
 
-    // 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);
-    will_return(__wrap_f_file_stat, &stat_directory);
-    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);
 
     const int result = kt_main_test__remove(3, argv, 0);
index 046e160a8339191b0270f971c10349b1c10e29ec..b41c300a9f90033d47ee3be7e90f46cb4cbd8032 100644 (file)
@@ -31,6 +31,9 @@ void test__kt_remove__directory_tree_simple__one_child_none_parent_one_exists_li
     will_return(__wrap_f_file_is, F_true); // A link, kt_remove_flag_operate_link_d is set.
     will_return(__wrap_f_file_stat, &stat_regular);
     will_return(__wrap_f_file_stat, F_okay);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
 
     // Target processing.
     will_return(__wrap_f_file_remove, F_okay);
@@ -40,6 +43,9 @@ void test__kt_remove__directory_tree_simple__one_child_none_parent_one_exists_li
     will_return(__wrap_f_file_is, F_false); // Not a link, kt_remove_flag_operate_link_d is not set.
     will_return(__wrap_f_file_stat, &stat_directory);
     will_return(__wrap_f_file_stat, F_okay);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
     will_return(__wrap_f_directory_empty, F_true);
 
     // Parent 1 processing.
@@ -75,6 +81,9 @@ void test__kt_remove__directory_tree_simple__one_child_none_parent_one_exists_li
     will_return(__wrap_f_file_is, F_false); // Not a link, kt_remove_flag_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_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
 
     // Target processing.
     will_return(__wrap_f_file_remove, F_okay);
@@ -84,6 +93,9 @@ void test__kt_remove__directory_tree_simple__one_child_none_parent_one_exists_li
     will_return(__wrap_f_file_is, F_false); // Not a link, kt_remove_flag_operate_link_d is not set.
     will_return(__wrap_f_file_stat, &stat_directory);
     will_return(__wrap_f_file_stat, F_okay);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
     will_return(__wrap_f_directory_empty, F_true);
 
     // Parent 1 processing.
@@ -119,6 +131,9 @@ void test__kt_remove__directory_tree_simple__one_child_none_parent_two_exists_li
     will_return(__wrap_f_file_is, F_true); // A link, kt_remove_flag_operate_link_d is set.
     will_return(__wrap_f_file_stat, &stat_regular);
     will_return(__wrap_f_file_stat, F_okay);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
 
     // Target processing.
     will_return(__wrap_f_file_remove, F_okay);
@@ -128,6 +143,9 @@ void test__kt_remove__directory_tree_simple__one_child_none_parent_two_exists_li
     will_return(__wrap_f_file_is, F_false); // Not a link, kt_remove_flag_operate_link_d is not set.
     will_return(__wrap_f_file_stat, &stat_directory);
     will_return(__wrap_f_file_stat, F_okay);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
     will_return(__wrap_f_directory_empty, F_true);
 
     // Parent 1 processing.
@@ -138,6 +156,9 @@ void test__kt_remove__directory_tree_simple__one_child_none_parent_two_exists_li
     will_return(__wrap_f_file_is, F_false); // Not a link, kt_remove_flag_operate_link_d is not set.
     will_return(__wrap_f_file_stat, &stat_directory);
     will_return(__wrap_f_file_stat, F_okay);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
     will_return(__wrap_f_directory_empty, F_true);
 
     // Parent 2 processing.
@@ -173,6 +194,9 @@ void test__kt_remove__directory_tree_simple__one_child_none_parent_two_exists_li
     will_return(__wrap_f_file_is, F_false); // Not a link, kt_remove_flag_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_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
 
     // Target processing.
     will_return(__wrap_f_file_remove, F_okay);
@@ -182,6 +206,9 @@ void test__kt_remove__directory_tree_simple__one_child_none_parent_two_exists_li
     will_return(__wrap_f_file_is, F_false); // Not a link, kt_remove_flag_operate_link_d is not set.
     will_return(__wrap_f_file_stat, &stat_directory);
     will_return(__wrap_f_file_stat, F_okay);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
     will_return(__wrap_f_directory_empty, F_true);
 
     // Parent 1 processing.
@@ -192,6 +219,9 @@ void test__kt_remove__directory_tree_simple__one_child_none_parent_two_exists_li
     will_return(__wrap_f_file_is, F_false); // Not a link, kt_remove_flag_operate_link_d is not set.
     will_return(__wrap_f_file_stat, &stat_directory);
     will_return(__wrap_f_file_stat, F_okay);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
     will_return(__wrap_f_directory_empty, F_true);
 
     // Parent 2 processing.
index 10204b9945850682b21af23a6a9b064e0e3ec6c2..559a2c80cc54890a259fba0f4bad56a0240331b6 100644 (file)
@@ -137,6 +137,9 @@ void test__kt_remove__epochtime__accessed_works(void **state) {
           will_return(__wrap_f_file_is, macro_f_file_type_is_link(stats[type].st_mode));
           will_return(__wrap_f_file_stat, &stats[type]);
           will_return(__wrap_f_file_stat, F_okay);
+          will_return(__wrap_f_file_access, F_true);
+          will_return(__wrap_f_file_access, F_true);
+          will_return(__wrap_f_file_access, F_true);
 
           if (macro_f_file_type_is_directory(stats[type].st_mode)) {
             will_return(__wrap_f_directory_empty, F_true);
@@ -144,19 +147,12 @@ void test__kt_remove__epochtime__accessed_works(void **state) {
             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, 0);
             will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_d | f_directory_recurse_do_flag_directory_d);
           }
 
           if (time_spec_removes[date]) {
             if (macro_f_file_type_is_directory(stats[type].st_mode)) {
-
-              // 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, macro_f_file_type_is_link(stats[type].st_mode));
-              will_return(__wrap_f_file_stat, &stats[type]);
-              will_return(__wrap_f_file_stat, F_okay);
-              will_return(__wrap_f_directory_empty, F_true);
-
               will_return(__wrap_f_directory_remove, F_okay);
             }
             else {
@@ -303,6 +299,9 @@ void test__kt_remove__epochtime__changed_works(void **state) {
           will_return(__wrap_f_file_is, macro_f_file_type_is_link(stats[type].st_mode));
           will_return(__wrap_f_file_stat, &stats[type]);
           will_return(__wrap_f_file_stat, F_okay);
+          will_return(__wrap_f_file_access, F_true);
+          will_return(__wrap_f_file_access, F_true);
+          will_return(__wrap_f_file_access, F_true);
 
           if (macro_f_file_type_is_directory(stats[type].st_mode)) {
             will_return(__wrap_f_directory_empty, F_true);
@@ -310,19 +309,12 @@ void test__kt_remove__epochtime__changed_works(void **state) {
             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, 0);
             will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_d | f_directory_recurse_do_flag_directory_d);
           }
 
           if (time_spec_removes[date]) {
             if (macro_f_file_type_is_directory(stats[type].st_mode)) {
-
-              // 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, macro_f_file_type_is_link(stats[type].st_mode));
-              will_return(__wrap_f_file_stat, &stats[type]);
-              will_return(__wrap_f_file_stat, F_okay);
-              will_return(__wrap_f_directory_empty, F_true);
-
               will_return(__wrap_f_directory_remove, F_okay);
             }
             else {
@@ -469,6 +461,9 @@ void test__kt_remove__epochtime__updated_works(void **state) {
           will_return(__wrap_f_file_is, macro_f_file_type_is_link(stats[type].st_mode));
           will_return(__wrap_f_file_stat, &stats[type]);
           will_return(__wrap_f_file_stat, F_okay);
+          will_return(__wrap_f_file_access, F_true);
+          will_return(__wrap_f_file_access, F_true);
+          will_return(__wrap_f_file_access, F_true);
 
           if (macro_f_file_type_is_directory(stats[type].st_mode)) {
             will_return(__wrap_f_directory_empty, F_true);
@@ -476,19 +471,12 @@ void test__kt_remove__epochtime__updated_works(void **state) {
             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, 0);
             will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_d | f_directory_recurse_do_flag_directory_d);
           }
 
           if (time_spec_removes[date]) {
             if (macro_f_file_type_is_directory(stats[type].st_mode)) {
-
-              // 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, macro_f_file_type_is_link(stats[type].st_mode));
-              will_return(__wrap_f_file_stat, &stats[type]);
-              will_return(__wrap_f_file_stat, F_okay);
-              will_return(__wrap_f_directory_empty, F_true);
-
               will_return(__wrap_f_directory_remove, F_okay);
             }
             else {
index 81ea3024538d534674af37801a5fb35391f78451..89d599eb7981cdc980e3b9e2b0cbeb76f905b4a7 100644 (file)
@@ -83,6 +83,9 @@ void test__kt_remove__file_mode__different_works(void **state) {
           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);
+          will_return(__wrap_f_file_access, F_true);
+          will_return(__wrap_f_file_access, F_true);
+          will_return(__wrap_f_file_access, F_true);
 
           if (macro_f_file_type_is_directory(statistics.st_mode)) {
             will_return(__wrap_f_directory_empty, F_true);
@@ -90,20 +93,13 @@ void test__kt_remove__file_mode__different_works(void **state) {
             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, 0);
             will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_d | f_directory_recurse_do_flag_directory_d);
           }
 
           // Process file.
           if (param != mode) {
             if (macro_f_file_type_is_directory(statistics.st_mode)) {
-
-              // 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, macro_f_file_type_is_link(statistics.st_mode));
-              will_return(__wrap_f_file_stat, &statistics);
-              will_return(__wrap_f_file_stat, F_okay);
-              will_return(__wrap_f_directory_empty, F_true);
-
               will_return(__wrap_f_directory_remove, F_okay);
             }
             else {
@@ -196,6 +192,9 @@ void test__kt_remove__file_mode__same_works(void **state) {
           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);
+          will_return(__wrap_f_file_access, F_true);
+          will_return(__wrap_f_file_access, F_true);
+          will_return(__wrap_f_file_access, F_true);
 
           if (macro_f_file_type_is_directory(statistics.st_mode)) {
             will_return(__wrap_f_directory_empty, F_true);
@@ -203,20 +202,13 @@ void test__kt_remove__file_mode__same_works(void **state) {
             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, 0);
             will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_d | f_directory_recurse_do_flag_directory_d);
           }
 
           // Process file.
           if (param == mode) {
             if (macro_f_file_type_is_directory(statistics.st_mode)) {
-
-              // 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, macro_f_file_type_is_link(statistics.st_mode));
-              will_return(__wrap_f_file_stat, &statistics);
-              will_return(__wrap_f_file_stat, F_okay);
-              will_return(__wrap_f_directory_empty, F_true);
-
               will_return(__wrap_f_directory_remove, F_okay);
             }
             else {
@@ -309,26 +301,22 @@ void test__kt_remove__file_mode__similar_works(void **state) {
           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);
+          will_return(__wrap_f_file_access, F_true);
+          will_return(__wrap_f_file_access, F_true);
+          will_return(__wrap_f_file_access, F_true);
 
           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, 0);
             will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_d | f_directory_recurse_do_flag_directory_d);
           }
 
           // Process file.
           if (modes[param] & modes[mode]) {
             if (macro_f_file_type_is_directory(statistics.st_mode)) {
-
-              // 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, macro_f_file_type_is_link(statistics.st_mode));
-              will_return(__wrap_f_file_stat, &statistics);
-              will_return(__wrap_f_file_stat, F_okay);
-              will_return(__wrap_f_directory_empty, F_true);
-
               will_return(__wrap_f_directory_remove, F_okay);
             }
             else {
@@ -421,6 +409,9 @@ void test__kt_remove__file_mode__not_works(void **state) {
           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);
+          will_return(__wrap_f_file_access, F_true);
+          will_return(__wrap_f_file_access, F_true);
+          will_return(__wrap_f_file_access, F_true);
 
           if (macro_f_file_type_is_directory(statistics.st_mode)) {
             will_return(__wrap_f_directory_empty, F_true);
@@ -428,20 +419,13 @@ void test__kt_remove__file_mode__not_works(void **state) {
             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, 0);
             will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_d | f_directory_recurse_do_flag_directory_d);
           }
 
           // Process file.
           if (modes[param] != modes[mode]) {
             if (macro_f_file_type_is_directory(statistics.st_mode)) {
-
-              // 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, macro_f_file_type_is_link(statistics.st_mode));
-              will_return(__wrap_f_file_stat, &statistics);
-              will_return(__wrap_f_file_stat, F_okay);
-              will_return(__wrap_f_directory_empty, F_true);
-
               will_return(__wrap_f_directory_remove, F_okay);
             }
             else {
index ee53b1d9ac6a716dfc394486145b2593c949e7fc..408d7c8ba61fdb22826c4f9e314d65e0a2bf046b 100644 (file)
@@ -50,32 +50,40 @@ void test__kt_remove__file_type__works(void **state) {
 
         const f_string_t argv[] = { "mocked_main", target.string, types[type], 0 };
 
-        // Pre-process file.
+        // Pre-process target.
         will_return(__wrap_f_file_exists, F_true);
         will_return(__wrap_f_file_is, macro_f_file_type_is_link(stats[i].st_mode));
         will_return(__wrap_f_file_stat, &stats[i]);
         will_return(__wrap_f_file_stat, F_okay);
+        will_return(__wrap_f_file_access, F_true);
+        will_return(__wrap_f_file_access, F_true);
+        will_return(__wrap_f_file_access, F_true);
 
-        // Process file.
-        if (i == type) {
-          if (macro_f_file_type_is_directory(stats[i].st_mode)) {
-            will_return(__wrap_f_directory_empty, F_true);
+        if (macro_f_file_type_is_directory(stats[i].st_mode)) {
+
+          // Top directory processing.
+          will_return(__wrap_f_directory_empty, F_true); // kt_remove_flag_operate_empty_d is set.
+          will_return(__wrap_fl_directory_do, i == type ? 2 : 1);
+
+          // Begin top path.
+          will_return(__wrap_fl_directory_do, &target);
+          will_return(__wrap_fl_directory_do, &target);
+          will_return(__wrap_fl_directory_do, 0);
+          will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_before_d | f_directory_recurse_do_flag_directory_d);
+
+          if (i == type) {
 
-            will_return(__wrap_fl_directory_do, 1);
+            // End top path.
             will_return(__wrap_fl_directory_do, &target);
             will_return(__wrap_fl_directory_do, &target);
+            will_return(__wrap_fl_directory_do, 0);
             will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_d | f_directory_recurse_do_flag_directory_d);
           }
+        }
 
+        // Process target.
+        if (i == type) {
           if (macro_f_file_type_is_directory(stats[i].st_mode)) {
-
-            // 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, macro_f_file_type_is_link(stats[i].st_mode));
-            will_return(__wrap_f_file_stat, &stats[i]);
-            will_return(__wrap_f_file_stat, F_okay);
-            will_return(__wrap_f_directory_empty, F_true);
-
             will_return(__wrap_f_directory_remove, F_okay);
           }
           else {
index 2f5a0932074b87a50bed42cbaff779d0cd904f48..368694f038a6ea2c20dcad9697d231207fa163bf 100644 (file)
@@ -42,6 +42,9 @@ void test__kt_remove__group__name_works(void **state) {
     will_return(__wrap_f_file_is, F_false); // Not a link, kt_remove_flag_operate_link_d is not set.
     will_return(__wrap_f_file_stat, &stats[type]);
     will_return(__wrap_f_file_stat, F_okay);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
 
     if (macro_f_file_type_is_directory(stats[type].st_mode)) {
       will_return(__wrap_f_directory_empty, F_true);
@@ -49,20 +52,13 @@ void test__kt_remove__group__name_works(void **state) {
       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, 0);
       will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_d | f_directory_recurse_do_flag_directory_d);
     }
 
     // Process file.
     if (stats[type].st_gid == group_id) {
       if (macro_f_file_type_is_directory(stats[type].st_mode)) {
-
-        // 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, macro_f_file_type_is_link(stats[type].st_mode));
-        will_return(__wrap_f_file_stat, &stats[type]);
-        will_return(__wrap_f_file_stat, F_okay);
-        will_return(__wrap_f_directory_empty, F_true);
-
         will_return(__wrap_f_directory_remove, F_okay);
       }
       else {
index 9d98695e141d5786715fd29928b7958b6eb0efdd..69ae8bbcee37059b89a2f3069f6cfa4360f5091f 100644 (file)
@@ -25,6 +25,9 @@ void test__kt_remove__regular_no_args__one_exists_link(void **state) {
     will_return(__wrap_f_file_is, F_true); // A link, kt_remove_flag_operate_link_d is set.
     will_return(__wrap_f_file_stat, &statistics);
     will_return(__wrap_f_file_stat, F_okay);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
 
     // This will fail if f_file_remove() is not called, therefore success here means f_file_remove has been called.
     will_return(__wrap_f_file_remove, F_okay);
@@ -45,6 +48,9 @@ void test__kt_remove__regular_no_args__one_exists_link(void **state) {
     will_return(__wrap_f_file_is, F_true); // A link, kt_remove_flag_operate_link_d is set.
     will_return(__wrap_f_file_stat, &statistics);
     will_return(__wrap_f_file_stat, F_okay);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
 
     // This will fail if f_file_remove() is not called, therefore success here means f_file_remove has been called.
     will_return(__wrap_f_file_remove, F_okay);
@@ -65,6 +71,9 @@ void test__kt_remove__regular_no_args__one_exists_link(void **state) {
     will_return(__wrap_f_file_is, F_true); // A link, kt_remove_flag_operate_link_d is set.
     will_return(__wrap_f_file_stat, &statistics);
     will_return(__wrap_f_file_stat, F_okay);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
 
     // This will fail if f_file_remove() is not called, therefore success here means f_file_remove has been called.
     will_return(__wrap_f_file_remove, F_okay);
@@ -93,6 +102,9 @@ void test__kt_remove__regular_no_args__one_exists_link_not(void **state) {
     will_return(__wrap_f_file_is, F_false); // Not a link, kt_remove_flag_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_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
 
     // This will fail if f_file_remove() is not called, therefore success here means f_file_remove has been called.
     will_return(__wrap_f_file_remove, F_okay);
@@ -113,6 +125,9 @@ void test__kt_remove__regular_no_args__one_exists_link_not(void **state) {
     will_return(__wrap_f_file_is, F_false); // Not a link, kt_remove_flag_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_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
 
     // This will fail if f_file_remove() is not called, therefore success here means f_file_remove has been called.
     will_return(__wrap_f_file_remove, F_okay);
@@ -133,6 +148,9 @@ void test__kt_remove__regular_no_args__one_exists_link_not(void **state) {
     will_return(__wrap_f_file_is, F_false); // Not a link, kt_remove_flag_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_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
 
     // This will fail if f_file_remove() is not called, therefore success here means f_file_remove has been called.
     will_return(__wrap_f_file_remove, F_okay);
@@ -194,6 +212,7 @@ void test__kt_remove__regular_no_args__two_exists_and_not(void **state) {
 
     // Pre-process file 1.
     will_return(__wrap_f_file_exists, F_false);
+    will_return(__wrap_f_file_exists, F_false);
 
     const int result = kt_main_test__remove(3, argv, 0);
 
@@ -208,6 +227,7 @@ void test__kt_remove__regular_no_args__two_exists_and_not(void **state) {
 
     // Pre-process file 1.
     will_return(__wrap_f_file_exists, F_false);
+    will_return(__wrap_f_file_exists, F_false);
 
     const int result = kt_main_test__remove(4, argv, 0);
 
@@ -222,6 +242,7 @@ void test__kt_remove__regular_no_args__two_exists_and_not(void **state) {
 
     // Pre-process file 1.
     will_return(__wrap_f_file_exists, F_false);
+    will_return(__wrap_f_file_exists, F_false);
 
     const int result = kt_main_test__remove(4, argv, 0);
 
@@ -247,6 +268,9 @@ void test__kt_remove__regular_no_args__two_exists_link(void **state) {
     will_return(__wrap_f_file_is, F_true); // A link, kt_remove_flag_operate_link_d is set.
     will_return(__wrap_f_file_stat, &statistics);
     will_return(__wrap_f_file_stat, F_okay);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
 
     // This will fail if f_file_remove() is not called, therefore success here means f_file_remove has been called.
     will_return(__wrap_f_file_remove, F_okay);
@@ -256,6 +280,9 @@ void test__kt_remove__regular_no_args__two_exists_link(void **state) {
     will_return(__wrap_f_file_is, F_true); // A link, kt_remove_flag_operate_link_d is set.
     will_return(__wrap_f_file_stat, &statistics);
     will_return(__wrap_f_file_stat, F_okay);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
 
     // This will fail if f_file_remove() is not called, therefore success here means f_file_remove has been called.
     will_return(__wrap_f_file_remove, F_okay);
@@ -276,6 +303,9 @@ void test__kt_remove__regular_no_args__two_exists_link(void **state) {
     will_return(__wrap_f_file_is, F_true); // A link, kt_remove_flag_operate_link_d is set.
     will_return(__wrap_f_file_stat, &statistics);
     will_return(__wrap_f_file_stat, F_okay);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
 
     // This will fail if f_file_remove() is not called, therefore success here means f_file_remove has been called.
     will_return(__wrap_f_file_remove, F_okay);
@@ -285,6 +315,9 @@ void test__kt_remove__regular_no_args__two_exists_link(void **state) {
     will_return(__wrap_f_file_is, F_true); // A link, kt_remove_flag_operate_link_d is set.
     will_return(__wrap_f_file_stat, &statistics);
     will_return(__wrap_f_file_stat, F_okay);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
 
     // This will fail if f_file_remove() is not called, therefore success here means f_file_remove has been called.
     will_return(__wrap_f_file_remove, F_okay);
@@ -305,6 +338,9 @@ void test__kt_remove__regular_no_args__two_exists_link(void **state) {
     will_return(__wrap_f_file_is, F_true); // A link, kt_remove_flag_operate_link_d is set.
     will_return(__wrap_f_file_stat, &statistics);
     will_return(__wrap_f_file_stat, F_okay);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
 
     // This will fail if f_file_remove() is not called, therefore success here means f_file_remove has been called.
     will_return(__wrap_f_file_remove, F_okay);
@@ -314,6 +350,9 @@ void test__kt_remove__regular_no_args__two_exists_link(void **state) {
     will_return(__wrap_f_file_is, F_true); // A link, kt_remove_flag_operate_link_d is set.
     will_return(__wrap_f_file_stat, &statistics);
     will_return(__wrap_f_file_stat, F_okay);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
 
     // This will fail if f_file_remove() is not called, therefore success here means f_file_remove has been called.
     will_return(__wrap_f_file_remove, F_okay);
@@ -342,6 +381,9 @@ void test__kt_remove__regular_no_args__two_exists_link_not(void **state) {
     will_return(__wrap_f_file_is, F_false); // Not a link, kt_remove_flag_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_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
 
     // This will fail if f_file_remove() is not called, therefore success here means f_file_remove has been called.
     will_return(__wrap_f_file_remove, F_okay);
@@ -351,6 +393,9 @@ void test__kt_remove__regular_no_args__two_exists_link_not(void **state) {
     will_return(__wrap_f_file_is, F_false); // Not a link, kt_remove_flag_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_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
 
     // This will fail if f_file_remove() is not called, therefore success here means f_file_remove has been called.
     will_return(__wrap_f_file_remove, F_okay);
@@ -371,6 +416,9 @@ void test__kt_remove__regular_no_args__two_exists_link_not(void **state) {
     will_return(__wrap_f_file_is, F_false); // Not a link, kt_remove_flag_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_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
 
     // This will fail if f_file_remove() is not called, therefore success here means f_file_remove has been called.
     will_return(__wrap_f_file_remove, F_okay);
@@ -380,6 +428,9 @@ void test__kt_remove__regular_no_args__two_exists_link_not(void **state) {
     will_return(__wrap_f_file_is, F_false); // Not a link, kt_remove_flag_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_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
 
     // This will fail if f_file_remove() is not called, therefore success here means f_file_remove has been called.
     will_return(__wrap_f_file_remove, F_okay);
@@ -400,6 +451,9 @@ void test__kt_remove__regular_no_args__two_exists_link_not(void **state) {
     will_return(__wrap_f_file_is, F_false); // Not a link, kt_remove_flag_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_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
 
     // This will fail if f_file_remove() is not called, therefore success here means f_file_remove has been called.
     will_return(__wrap_f_file_remove, F_okay);
@@ -409,6 +463,9 @@ void test__kt_remove__regular_no_args__two_exists_link_not(void **state) {
     will_return(__wrap_f_file_is, F_false); // Not a link, kt_remove_flag_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_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
 
     // This will fail if f_file_remove() is not called, therefore success here means f_file_remove has been called.
     will_return(__wrap_f_file_remove, F_okay);
@@ -428,6 +485,7 @@ void test__kt_remove__regular_no_args__two_exists_not(void **state) {
     const f_string_t argv[] = { "mocked_main", "to_remove", "also/remove", 0 };
 
     will_return(__wrap_f_file_exists, F_false);
+    will_return(__wrap_f_file_exists, F_false);
 
     const int result = kt_main_test__remove(3, argv, 0);
 
@@ -438,6 +496,7 @@ void test__kt_remove__regular_no_args__two_exists_not(void **state) {
     const f_string_t argv[] = { "mocked_main", "to_remove", "also/remove", "+" F_console_standard_short_verbose_s, 0 };
 
     will_return(__wrap_f_file_exists, F_false);
+    will_return(__wrap_f_file_exists, F_false);
 
     const int result = kt_main_test__remove(4, argv, 0);
 
@@ -448,6 +507,7 @@ void test__kt_remove__regular_no_args__two_exists_not(void **state) {
     const f_string_t argv[] = { "mocked_main", "to_remove", "also/remove", "+" F_console_standard_short_debug_s, 0 };
 
     will_return(__wrap_f_file_exists, F_false);
+    will_return(__wrap_f_file_exists, F_false);
 
     const int result = kt_main_test__remove(4, argv, 0);
 
index f13a3ca67e4594e3662bb6da977d6dcc2dc5d971..b7aed04cce26a29d3a1ce5346d634ceca0ccb3b4 100644 (file)
@@ -139,6 +139,9 @@ void test__kt_remove__time__accessed_works(void **state) {
           will_return(__wrap_f_file_is, macro_f_file_type_is_link(stats[type].st_mode));
           will_return(__wrap_f_file_stat, &stats[type]);
           will_return(__wrap_f_file_stat, F_okay);
+          will_return(__wrap_f_file_access, F_true);
+          will_return(__wrap_f_file_access, F_true);
+          will_return(__wrap_f_file_access, F_true);
 
           if (param) {
             will_return(__wrap_f_time_clock_get, &time_spec_clocks);
@@ -151,19 +154,12 @@ void test__kt_remove__time__accessed_works(void **state) {
             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, 0);
             will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_d | f_directory_recurse_do_flag_directory_d);
           }
 
           if (time_spec_removes[date]) {
             if (macro_f_file_type_is_directory(stats[type].st_mode)) {
-
-              // 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, macro_f_file_type_is_link(stats[type].st_mode));
-              will_return(__wrap_f_file_stat, &stats[type]);
-              will_return(__wrap_f_file_stat, F_okay);
-              will_return(__wrap_f_directory_empty, F_true);
-
               will_return(__wrap_f_directory_remove, F_okay);
             }
             else {
@@ -312,6 +308,9 @@ void test__kt_remove__time__changed_works(void **state) {
           will_return(__wrap_f_file_is, macro_f_file_type_is_link(stats[type].st_mode));
           will_return(__wrap_f_file_stat, &stats[type]);
           will_return(__wrap_f_file_stat, F_okay);
+          will_return(__wrap_f_file_access, F_true);
+          will_return(__wrap_f_file_access, F_true);
+          will_return(__wrap_f_file_access, F_true);
 
           if (param) {
             will_return(__wrap_f_time_clock_get, &time_spec_clocks);
@@ -324,19 +323,12 @@ void test__kt_remove__time__changed_works(void **state) {
             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, 0);
             will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_d | f_directory_recurse_do_flag_directory_d);
           }
 
           if (time_spec_removes[date]) {
             if (macro_f_file_type_is_directory(stats[type].st_mode)) {
-
-              // 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, macro_f_file_type_is_link(stats[type].st_mode));
-              will_return(__wrap_f_file_stat, &stats[type]);
-              will_return(__wrap_f_file_stat, F_okay);
-              will_return(__wrap_f_directory_empty, F_true);
-
               will_return(__wrap_f_directory_remove, F_okay);
             }
             else {
@@ -485,6 +477,9 @@ void test__kt_remove__time__updated_works(void **state) {
           will_return(__wrap_f_file_is, macro_f_file_type_is_link(stats[type].st_mode));
           will_return(__wrap_f_file_stat, &stats[type]);
           will_return(__wrap_f_file_stat, F_okay);
+          will_return(__wrap_f_file_access, F_true);
+          will_return(__wrap_f_file_access, F_true);
+          will_return(__wrap_f_file_access, F_true);
 
           if (param) {
             will_return(__wrap_f_time_clock_get, &time_spec_clocks);
@@ -497,19 +492,12 @@ void test__kt_remove__time__updated_works(void **state) {
             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, 0);
             will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_d | f_directory_recurse_do_flag_directory_d);
           }
 
           if (time_spec_removes[date]) {
             if (macro_f_file_type_is_directory(stats[type].st_mode)) {
-
-              // 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, macro_f_file_type_is_link(stats[type].st_mode));
-              will_return(__wrap_f_file_stat, &stats[type]);
-              will_return(__wrap_f_file_stat, F_okay);
-              will_return(__wrap_f_directory_empty, F_true);
-
               will_return(__wrap_f_directory_remove, F_okay);
             }
             else {
index 41824b028606ce9af5aa9bcb98efb4d759f4af3b..876a5fc461ad301ffd4914c78bed33888390b673 100644 (file)
@@ -131,6 +131,9 @@ void test__kt_remove__unix__accessed_works(void **state) {
         will_return(__wrap_f_file_is, macro_f_file_type_is_link(stats[type].st_mode));
         will_return(__wrap_f_file_stat, &stats[type]);
         will_return(__wrap_f_file_stat, F_okay);
+        will_return(__wrap_f_file_access, F_true);
+        will_return(__wrap_f_file_access, F_true);
+        will_return(__wrap_f_file_access, F_true);
 
         if (macro_f_file_type_is_directory(stats[type].st_mode)) {
           will_return(__wrap_f_directory_empty, F_true);
@@ -138,19 +141,12 @@ void test__kt_remove__unix__accessed_works(void **state) {
           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, 0);
           will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_d | f_directory_recurse_do_flag_directory_d);
         }
 
         if (time_spec_removes[date]) {
           if (macro_f_file_type_is_directory(stats[type].st_mode)) {
-
-            // 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, macro_f_file_type_is_link(stats[type].st_mode));
-            will_return(__wrap_f_file_stat, &stats[type]);
-            will_return(__wrap_f_file_stat, F_okay);
-            will_return(__wrap_f_directory_empty, F_true);
-
             will_return(__wrap_f_directory_remove, F_okay);
           }
           else {
@@ -289,6 +285,9 @@ void test__kt_remove__unix__changed_works(void **state) {
         will_return(__wrap_f_file_is, macro_f_file_type_is_link(stats[type].st_mode));
         will_return(__wrap_f_file_stat, &stats[type]);
         will_return(__wrap_f_file_stat, F_okay);
+        will_return(__wrap_f_file_access, F_true);
+        will_return(__wrap_f_file_access, F_true);
+        will_return(__wrap_f_file_access, F_true);
 
         if (macro_f_file_type_is_directory(stats[type].st_mode)) {
           will_return(__wrap_f_directory_empty, F_true);
@@ -296,19 +295,12 @@ void test__kt_remove__unix__changed_works(void **state) {
           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, 0);
           will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_d | f_directory_recurse_do_flag_directory_d);
         }
 
         if (time_spec_removes[date]) {
           if (macro_f_file_type_is_directory(stats[type].st_mode)) {
-
-            // 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, macro_f_file_type_is_link(stats[type].st_mode));
-            will_return(__wrap_f_file_stat, &stats[type]);
-            will_return(__wrap_f_file_stat, F_okay);
-            will_return(__wrap_f_directory_empty, F_true);
-
             will_return(__wrap_f_directory_remove, F_okay);
           }
           else {
@@ -447,6 +439,9 @@ void test__kt_remove__unix__updated_works(void **state) {
         will_return(__wrap_f_file_is, macro_f_file_type_is_link(stats[type].st_mode));
         will_return(__wrap_f_file_stat, &stats[type]);
         will_return(__wrap_f_file_stat, F_okay);
+          will_return(__wrap_f_file_access, F_true);
+          will_return(__wrap_f_file_access, F_true);
+          will_return(__wrap_f_file_access, F_true);
 
         if (macro_f_file_type_is_directory(stats[type].st_mode)) {
           will_return(__wrap_f_directory_empty, F_true);
@@ -454,19 +449,12 @@ void test__kt_remove__unix__updated_works(void **state) {
           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, 0);
           will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_d | f_directory_recurse_do_flag_directory_d);
         }
 
         if (time_spec_removes[date]) {
           if (macro_f_file_type_is_directory(stats[type].st_mode)) {
-
-            // 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, macro_f_file_type_is_link(stats[type].st_mode));
-            will_return(__wrap_f_file_stat, &stats[type]);
-            will_return(__wrap_f_file_stat, F_okay);
-            will_return(__wrap_f_directory_empty, F_true);
-
             will_return(__wrap_f_directory_remove, F_okay);
           }
           else {
index 05ecfe5d0a7bf19f0917fd5e892e0e8683bade61..54f89f1a33f77eb39b60d2a6cc961d933179cde4 100644 (file)
@@ -42,28 +42,22 @@ void test__kt_remove__user__different_works(void **state) {
     will_return(__wrap_f_file_is, F_false); // Not a link, kt_remove_flag_operate_link_d is not set.
     will_return(__wrap_f_file_stat, &stats[type]);
     will_return(__wrap_f_file_stat, F_okay);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
 
     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, 0);
       will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_d | f_directory_recurse_do_flag_directory_d);
     }
 
     // Process file.
     if (stats[type].st_uid != user_id) {
       if (macro_f_file_type_is_directory(stats[type].st_mode)) {
-
-        // The pre-process gets called again before the final removal for directories.
-        will_return(__wrap_geteuid, user_id);
-        will_return(__wrap_geteuid, user_id);
-        will_return(__wrap_f_file_exists, F_true);
-        will_return(__wrap_f_file_is, F_false);
-        will_return(__wrap_f_file_stat, &stats[type]);
-        will_return(__wrap_f_file_stat, F_okay);
-        will_return(__wrap_f_directory_empty, F_true);
-
         will_return(__wrap_f_directory_remove, F_okay);
       }
       else {
@@ -112,26 +106,22 @@ void test__kt_remove__user__name_works(void **state) {
     will_return(__wrap_f_file_is, F_false); // Not a link, kt_remove_flag_operate_link_d is not set.
     will_return(__wrap_f_file_stat, &stats[type]);
     will_return(__wrap_f_file_stat, F_okay);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
 
     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, 0);
       will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_d | f_directory_recurse_do_flag_directory_d);
     }
 
     // Process file.
     if (stats[type].st_uid == user_id) {
       if (macro_f_file_type_is_directory(stats[type].st_mode)) {
-
-        // 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);
-        will_return(__wrap_f_file_stat, &stats[type]);
-        will_return(__wrap_f_file_stat, F_okay);
-        will_return(__wrap_f_directory_empty, F_true);
-
         will_return(__wrap_f_directory_remove, F_okay);
       }
       else {
@@ -180,28 +170,22 @@ void test__kt_remove__user__same_works(void **state) {
     will_return(__wrap_f_file_is, F_false); // Not a link, kt_remove_flag_operate_link_d is not set.
     will_return(__wrap_f_file_stat, &stats[type]);
     will_return(__wrap_f_file_stat, F_okay);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
+    will_return(__wrap_f_file_access, F_true);
 
     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, 0);
       will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_d | f_directory_recurse_do_flag_directory_d);
     }
 
     // Process file.
     if (stats[type].st_uid == user_id) {
       if (macro_f_file_type_is_directory(stats[type].st_mode)) {
-
-        // The pre-process gets called again before the final removal for directories.
-        will_return(__wrap_geteuid, user_id);
-        will_return(__wrap_geteuid, user_id);
-        will_return(__wrap_f_file_exists, F_true);
-        will_return(__wrap_f_file_is, F_false);
-        will_return(__wrap_f_file_stat, &stats[type]);
-        will_return(__wrap_f_file_stat, F_okay);
-        will_return(__wrap_f_directory_empty, F_true);
-
         will_return(__wrap_f_directory_remove, F_okay);
       }
       else {