From: Kevin Day Date: Mon, 21 Apr 2025 03:18:08 +0000 (-0500) Subject: Progress: Continue working on completing the remove program. X-Git-Tag: 0.7.1~6 X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=27a00c8fe54a63aa76e056ddef11cc04bd0f8449;p=kevux-tools Progress: Continue working on completing the remove program. Update to the latest FLL changes. The FLL changes include parameter processing changes to support the `--` parameter as a stop processing parameters option. Enable this and remove the manual process that was previously performed. Add the root path check. Make sure a parameter exists in the `remove` program to toggle this behavior. A lot of the simulate and directory recursion behavior is now dead code due to the recent recursion changes. Remove the dead code and simplify the parameters. Update the unit tests. I noticed some situations in the unit tests that could be improved to be more accurate and correct. An `@fixme` has been added to accomplish this. --- diff --git a/data/build/stand_alone/configs/remove-config.h b/data/build/stand_alone/configs/remove-config.h index a3224d0..b5110cb 100644 --- a/data/build/stand_alone/configs/remove-config.h +++ b/data/build/stand_alone/configs/remove-config.h @@ -155,7 +155,7 @@ #define _di_f_compare_utf_utf_string_dynamic_partial_trim_ //#define _di_f_console_arguments_t_ #define _di_f_console_environment_process_ -//#define _di_f_console_flag_e_ +//#define _di_f_console_flag_d_ //#define _di_f_console_flag_t_ #define _di_f_console_identify_ //#define _di_f_console_length_size_d_ @@ -171,7 +171,7 @@ //#define _di_f_console_parameters_delete_ #define _di_f_console_parameters_destroy_ //#define _di_f_console_parameters_t_ -//#define _di_f_console_result_e_ +//#define _di_f_console_result_d_ //#define _di_f_console_result_t_ //#define _di_f_console_standard_long_copyright_s_ //#define _di_f_console_standard_long_dark_s_ @@ -234,7 +234,7 @@ #define _di_f_date_t_ #define _di_f_directory_at_d_ //#define _di_f_directory_back_s_ -#define _di_f_directory_close_ +//#define _di_f_directory_stream_close_ //#define _di_f_directory_compare_call_t_ #define _di_f_directory_create_ #define _di_f_directory_create_at_ @@ -271,6 +271,13 @@ #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_ @@ -889,7 +896,7 @@ #define _di_f_string_constant_t_ #define _di_f_string_dynamic_append_ //#define _di_f_string_dynamic_append_assure_ -#define _di_f_string_dynamic_append_assure_nulless_ +//#define _di_f_string_dynamic_append_assure_nulless_ //#define _di_f_string_dynamic_append_nulless_ #define _di_f_string_dynamic_mash_ #define _di_f_string_dynamic_mash_nulless_ diff --git a/sources/c/program/kevux/tools/remove/main/common.c b/sources/c/program/kevux/tools/remove/main/common.c index be56022..061bdb6 100644 --- a/sources/c/program/kevux/tools/remove/main/common.c +++ b/sources/c/program/kevux/tools/remove/main/common.c @@ -20,19 +20,19 @@ extern "C" { uint8_t j = 0; - if (main->program.parameters.array[kt_remove_parameter_block_e].result & f_console_result_found_e) { + if (main->program.parameters.array[kt_remove_parameter_block_e].result & f_console_result_found_d) { main->setting.flag |= kt_remove_main_flag_block_d | kt_remove_main_flag_option_type_d | kt_remove_main_flag_option_used_d; } - if (main->program.parameters.array[kt_remove_parameter_character_e].result & f_console_result_found_e) { + if (main->program.parameters.array[kt_remove_parameter_character_e].result & f_console_result_found_d) { main->setting.flag |= kt_remove_main_flag_character_d | kt_remove_main_flag_option_type_d | kt_remove_main_flag_option_used_d; } - if (main->program.parameters.array[kt_remove_parameter_different_e].result & f_console_result_found_e) { + if (main->program.parameters.array[kt_remove_parameter_different_e].result & f_console_result_found_d) { main->setting.flag &= ~kt_remove_main_flag_same_d; main->setting.flag |= kt_remove_main_flag_different_d | kt_remove_main_flag_option_used_d; - if (main->program.parameters.array[kt_remove_parameter_same_e].result & f_console_result_found_e) { + if (main->program.parameters.array[kt_remove_parameter_same_e].result & f_console_result_found_d) { index = main->program.parameters.array[kt_remove_parameter_different_e].locations.used; index2 = main->program.parameters.array[kt_remove_parameter_same_e].locations.used; @@ -42,19 +42,19 @@ extern "C" { } } } - else if (main->program.parameters.array[kt_remove_parameter_same_e].result & f_console_result_found_e) { + else if (main->program.parameters.array[kt_remove_parameter_same_e].result & f_console_result_found_d) { main->setting.flag &= ~kt_remove_main_flag_different_d; main->setting.flag |= kt_remove_main_flag_same_d | kt_remove_main_flag_option_used_d; } - if (main->program.parameters.array[kt_remove_parameter_fifo_e].result & f_console_result_found_e) { + if (main->program.parameters.array[kt_remove_parameter_fifo_e].result & f_console_result_found_d) { main->setting.flag |= kt_remove_main_flag_fifo_d | kt_remove_main_flag_option_type_d | kt_remove_main_flag_option_used_d; } - if (main->program.parameters.array[kt_remove_parameter_follow_e].result & f_console_result_found_e) { + if (main->program.parameters.array[kt_remove_parameter_follow_e].result & f_console_result_found_d) { main->setting.flag |= kt_remove_main_flag_follow_d; - if (main->program.parameters.array[kt_remove_parameter_stay_e].result & f_console_result_found_e) { + if (main->program.parameters.array[kt_remove_parameter_stay_e].result & f_console_result_found_d) { index = main->program.parameters.array[kt_remove_parameter_follow_e].locations.used; index2 = main->program.parameters.array[kt_remove_parameter_stay_e].locations.used; @@ -63,46 +63,50 @@ extern "C" { } } } - else if (main->program.parameters.array[kt_remove_parameter_stay_e].result & f_console_result_found_e) { + else if (main->program.parameters.array[kt_remove_parameter_stay_e].result & f_console_result_found_d) { main->setting.flag &= ~kt_remove_main_flag_follow_d; } - if (main->program.parameters.array[kt_remove_parameter_directory_e].result & f_console_result_found_e) { + if (main->program.parameters.array[kt_remove_parameter_directory_e].result & f_console_result_found_d) { main->setting.flag |= kt_remove_main_flag_directory_d | kt_remove_main_flag_option_type_d | kt_remove_main_flag_option_used_d; } - if (main->program.parameters.array[kt_remove_parameter_force_e].result & f_console_result_found_e) { + if (main->program.parameters.array[kt_remove_parameter_force_e].result & f_console_result_found_d) { main->setting.flag |= kt_remove_main_flag_force_d; } - if (main->program.parameters.array[kt_remove_parameter_link_e].result & f_console_result_found_e) { + if (main->program.parameters.array[kt_remove_parameter_link_e].result & f_console_result_found_d) { main->setting.flag |= kt_remove_main_flag_link_d | kt_remove_main_flag_option_type_d | kt_remove_main_flag_option_used_d; } - if (main->program.parameters.array[kt_remove_parameter_recurse_e].result & f_console_result_found_e) { + if (main->program.parameters.array[kt_remove_parameter_recurse_e].result & f_console_result_found_d) { main->setting.flag |= kt_remove_main_flag_recurse_d; } - if (main->program.parameters.array[kt_remove_parameter_regular_e].result & f_console_result_found_e) { + if (main->program.parameters.array[kt_remove_parameter_regular_e].result & f_console_result_found_d) { main->setting.flag |= kt_remove_main_flag_regular_d | kt_remove_main_flag_option_type_d | kt_remove_main_flag_option_used_d; } - if (main->program.parameters.array[kt_remove_parameter_simulate_e].result & f_console_result_found_e) { + if (main->program.parameters.array[kt_remove_parameter_simulate_e].result & f_console_result_found_d) { main->setting.flag |= kt_remove_main_flag_simulate_d; } - if (main->program.parameters.array[kt_remove_parameter_socket_e].result & f_console_result_found_e) { + if (main->program.parameters.array[kt_remove_parameter_socket_e].result & f_console_result_found_d) { main->setting.flag |= kt_remove_main_flag_socket_d | kt_remove_main_flag_option_type_d | kt_remove_main_flag_option_used_d; } - if (main->program.parameters.array[kt_remove_parameter_tree_e].result & f_console_result_found_e) { + if (main->program.parameters.array[kt_remove_parameter_tree_e].result & f_console_result_found_d) { main->setting.flag |= kt_remove_main_flag_tree_d; } - if (main->program.parameters.array[kt_remove_parameter_unknown_e].result & f_console_result_found_e) { + if (main->program.parameters.array[kt_remove_parameter_unknown_e].result & f_console_result_found_d) { main->setting.flag |= kt_remove_main_flag_unknown_d | kt_remove_main_flag_option_type_d | kt_remove_main_flag_option_used_d; } + if (main->program.parameters.array[kt_remove_parameter_allow_root_e].result & f_console_result_found_d) { + main->setting.flag |= kt_remove_main_flag_root_d; + } + { f_console_parameter_t * const parameters[] = { &main->program.parameters.array[kt_remove_parameter_accessed_e], @@ -130,9 +134,9 @@ extern "C" { for (uint8_t p = 0; p < 3; ++p) { - if (!(parameters[p]->result & f_console_result_found_e)) continue; + if (!(parameters[p]->result & f_console_result_found_d)) continue; - if (parameters[p]->result & f_console_result_value_e) { + if (parameters[p]->result & f_console_result_value_d) { total_locations = parameters[p]->locations.used; total_arguments = parameters[p]->values.used; @@ -235,8 +239,8 @@ extern "C" { } // for } - if (main->program.parameters.array[kt_remove_parameter_empty_e].result & f_console_result_found_e) { - if (main->program.parameters.array[kt_remove_parameter_empty_e].result & f_console_result_value_e) { + if (main->program.parameters.array[kt_remove_parameter_empty_e].result & f_console_result_found_d) { + if (main->program.parameters.array[kt_remove_parameter_empty_e].result & f_console_result_value_d) { total_arguments = main->program.parameters.array[kt_remove_parameter_empty_e].values.used; if (main->program.parameters.array[kt_remove_parameter_empty_e].locations.used != total_arguments) { @@ -283,8 +287,8 @@ extern "C" { kt_remove_setting_load_id(main, &main->program.parameters.array[kt_remove_parameter_group_e], &main->setting.groups, kt_remove_long_group_s, kt_remove_main_flag_group_d, F_false); if (F_status_is_error(main->setting.state.status)) return; - if (main->program.parameters.array[kt_remove_parameter_mode_e].result & f_console_result_found_e) { - if (main->program.parameters.array[kt_remove_parameter_mode_e].result & f_console_result_value_e) { + if (main->program.parameters.array[kt_remove_parameter_mode_e].result & f_console_result_found_d) { + if (main->program.parameters.array[kt_remove_parameter_mode_e].result & f_console_result_value_d) { total_locations = main->program.parameters.array[kt_remove_parameter_mode_e].locations.used; total_arguments = main->program.parameters.array[kt_remove_parameter_mode_e].values.used; @@ -373,8 +377,8 @@ extern "C" { kt_remove_setting_load_id(main, &main->program.parameters.array[kt_remove_parameter_user_e], &main->setting.users, kt_remove_long_user_s, kt_remove_main_flag_user_d, F_true); if (F_status_is_error(main->setting.state.status)) return; - if (main->program.parameters.array[kt_remove_parameter_prompt_e].result & f_console_result_found_e) { - if (main->program.parameters.array[kt_remove_parameter_prompt_e].result & f_console_result_value_e) { + if (main->program.parameters.array[kt_remove_parameter_prompt_e].result & f_console_result_found_d) { + if (main->program.parameters.array[kt_remove_parameter_prompt_e].result & f_console_result_value_d) { total_arguments = main->program.parameters.array[kt_remove_parameter_prompt_e].values.used; if (main->program.parameters.array[kt_remove_parameter_prompt_e].locations.used != total_arguments) { @@ -418,8 +422,8 @@ extern "C" { } } - if (main->program.parameters.array[kt_remove_parameter_remember_e].result & f_console_result_found_e) { - if (main->program.parameters.array[kt_remove_parameter_remember_e].result & f_console_result_value_e) { + if (main->program.parameters.array[kt_remove_parameter_remember_e].result & f_console_result_found_d) { + if (main->program.parameters.array[kt_remove_parameter_remember_e].result & f_console_result_value_d) { total_arguments = main->program.parameters.array[kt_remove_parameter_remember_e].values.used; if (main->program.parameters.array[kt_remove_parameter_remember_e].locations.used != total_arguments) { @@ -455,11 +459,11 @@ extern "C" { } } - if (main->program.parameters.array[kt_remove_parameter_utc_e].result & f_console_result_found_e) { + if (main->program.parameters.array[kt_remove_parameter_utc_e].result & f_console_result_found_d) { main->setting.flag |= kt_remove_main_flag_utc_d; // Use the right most parameter when both --utc and --local are passed. - if (main->program.parameters.array[kt_remove_parameter_local_e].result & f_console_result_found_e) { + if (main->program.parameters.array[kt_remove_parameter_local_e].result & f_console_result_found_d) { index = main->program.parameters.array[kt_remove_parameter_local_e].locations.array[main->program.parameters.array[kt_remove_parameter_local_e].locations.used]; index2 = main->program.parameters.array[kt_remove_parameter_utc_e].locations.array[main->program.parameters.array[kt_remove_parameter_utc_e].locations.used]; @@ -468,35 +472,11 @@ extern "C" { } } } - else if (main->program.parameters.array[kt_remove_parameter_local_e].result & f_console_result_found_e) { + else if (main->program.parameters.array[kt_remove_parameter_local_e].result & f_console_result_found_d) { main->setting.flag &= ~kt_remove_main_flag_utc_d; } - // Load all remaining files as static strings (setting size to 0). - if (main->program.parameters.remaining.used) { - main->setting.state.status = f_memory_array_increase_by(main->program.parameters.remaining.used, sizeof(f_string_dynamic_t), (void **) &main->setting.files.array, &main->setting.files.used, &main->setting.files.size); - - if (F_status_is_error(main->setting.state.status)) { - kt_remove_print_error(&main->program.error, macro_kt_remove_f(f_memory_array_increase_by)); - - return; - } - - for (i = 0; i < main->program.parameters.remaining.used; ++i, ++main->setting.files.used) { - - index = main->program.parameters.remaining.array[i]; - - main->setting.files.array[main->setting.files.used].used = 0; - - fl_path_clean(main->program.parameters.arguments.array[index], &main->setting.files.array[main->setting.files.used]); - - if (F_status_is_error(main->setting.state.status)) { - kt_remove_print_error_file(&main->program.error, macro_kt_remove_f(fl_path_clean), main->program.parameters.arguments.array[index], f_file_operation_process_s, fll_error_file_type_path_e); - - return; - } - } // for - } + kt_remove_setting_load_remaining(arguments, main); } #endif // _di_kt_remove_setting_load_ @@ -513,8 +493,8 @@ extern "C" { return; } - if (parameter->result & f_console_result_found_e) { - if (parameter->result & f_console_result_value_e) { + if (parameter->result & f_console_result_found_d) { + if (parameter->result & f_console_result_value_d) { const f_number_unsigned_t total_arguments = parameter->values.used; if (parameter->locations.used != total_arguments) { @@ -561,6 +541,42 @@ extern "C" { } #endif // _di_kt_remove_setting_load_id_ +#ifndef _di_kt_remove_setting_load_remaining_ + void kt_remove_setting_load_remaining(const f_console_arguments_t arguments, kt_remove_main_t * const main) { + + if (!main || F_status_is_error(main->setting.state.status)) return; + + if (main->program.parameters.remaining.used) { + main->setting.state.status = f_memory_array_increase_by(main->program.parameters.remaining.used, sizeof(f_string_dynamic_t), (void **) &main->setting.files.array, &main->setting.files.used, &main->setting.files.size); + + if (F_status_is_error(main->setting.state.status)) { + kt_remove_print_error(&main->program.error, macro_kt_remove_f(f_memory_array_increase_by)); + + return; + } + + f_number_unsigned_t index = 0; + + for (f_number_unsigned_t i = 0; i < main->program.parameters.remaining.used; ++i, ++main->setting.files.used) { + + index = main->program.parameters.remaining.array[i]; + + main->setting.files.array[main->setting.files.used].used = 0; + + fl_path_clean(main->program.parameters.arguments.array[index], &main->setting.files.array[main->setting.files.used]); + + if (F_status_is_error(main->setting.state.status)) { + kt_remove_print_error_file(&main->program.error, macro_kt_remove_f(fl_path_clean), main->program.parameters.arguments.array[index], f_file_operation_process_s, fll_error_file_type_path_e); + + return; + } + } // for + } + + main->setting.state.status = F_okay; + } +#endif // _di_kt_remove_setting_load_remaining_ + #ifndef _di_kt_remove_setting_load_standard_ void kt_remove_setting_load_standard(const f_console_arguments_t arguments, kt_remove_main_t * const main) { @@ -618,15 +634,15 @@ extern "C" { main->setting.flag &= ~kt_remove_main_flag_version_copyright_help_d; - if (main->program.parameters.array[f_console_standard_parameter_help_e].result & f_console_result_found_e) { + if (main->program.parameters.array[f_console_standard_parameter_help_e].result & f_console_result_found_d) { main->setting.flag |= kt_remove_main_flag_help_d; } - if (main->program.parameters.array[f_console_standard_parameter_version_e].result & f_console_result_found_e) { + if (main->program.parameters.array[f_console_standard_parameter_version_e].result & f_console_result_found_d) { main->setting.flag |= kt_remove_main_flag_version_d; } - if (main->program.parameters.array[f_console_standard_parameter_copyright_e].result & f_console_result_found_e) { + if (main->program.parameters.array[f_console_standard_parameter_copyright_e].result & f_console_result_found_d) { main->setting.flag |= kt_remove_main_flag_copyright_d; } } diff --git a/sources/c/program/kevux/tools/remove/main/common.h b/sources/c/program/kevux/tools/remove/main/common.h index 3cf4ba5..34f783d 100644 --- a/sources/c/program/kevux/tools/remove/main/common.h +++ b/sources/c/program/kevux/tools/remove/main/common.h @@ -89,6 +89,31 @@ extern "C" { #endif // _di_kt_remove_setting_load_id_ /** + * Load all remaining files as static strings (setting size to 0). + * + * This prints error messages as appropriate. + * + * @param arguments + * The parameters passed to the process (often referred to as command line arguments). + * @param main + * The main program and settings data. + * + * Must not be NULL. + * + * This alters setting.status: + * F_okay on success. + * + * Errors (with error bit) from: f_memory_array_increase_by(). + * Errors (with error bit) from: fl_path_clean(). + * + * @see f_memory_array_increase_by() + * @see fl_path_clean() + */ +#ifndef _di_kt_remove_setting_load_remaining_ + extern void kt_remove_setting_load_remaining(const f_console_arguments_t arguments, kt_remove_main_t * const main); +#endif // _di_kt_remove_setting_load_remaining_ + +/** * Perform the standard program setting load process, specifically handling the FLL standard parameters. * * This prints error messages as appropriate. diff --git a/sources/c/program/kevux/tools/remove/main/common/define.h b/sources/c/program/kevux/tools/remove/main/common/define.h index 97a7e23..6b95d8a 100644 --- a/sources/c/program/kevux/tools/remove/main/common/define.h +++ b/sources/c/program/kevux/tools/remove/main/common/define.h @@ -81,24 +81,16 @@ extern "C" { * Flags associated with performing an operation on a file. * * kt_remove_flag_simulate_*_d: - * - none: No flags set, simulate disabled, no "is" value. - * - directory: Simulate directory, not recursing. - * - directory_any: Helper used to represent the directory, directory_not, and directory_recurse bits. - * - directory_not: Simulate non-directory, not recursing. - * - directory_recurse: Simulate directory, recursing. - * - is_a: Print simulate message related to "is a ". - * - is_a_file: Helper used to print both simulate messages related to "is a " and "a file". - * - is_file: Print simulate message related to "a file". + * - none: No flags set, simulate disabled, no "is" value. + * - is_a: Print simulate message related to "is a ". + * - is_a_file: Helper used to print both simulate messages related to "is a " and "a file". + * - is_file: Print simulate message related to "a file". */ #ifndef _di_kt_remove_flag_file_simulate_d_ - #define kt_remove_flag_simulate_none_d 0x0 - #define kt_remove_flag_simulate_directory_d 0x1 - #define kt_remove_flag_simulate_directory_any_d 0x7 - #define kt_remove_flag_simulate_directory_not_d 0x2 - #define kt_remove_flag_simulate_directory_recurse_d 0x4 - #define kt_remove_flag_simulate_is_a_d 0x8 - #define kt_remove_flag_simulate_is_a_file_d 0x18 - #define kt_remove_flag_simulate_is_file_d 0x10 + #define kt_remove_flag_simulate_none_d 0x0 + #define kt_remove_flag_simulate_is_a_d 0x1 + #define kt_remove_flag_simulate_is_a_file_d 0x3 + #define kt_remove_flag_simulate_is_file_d 0x2 #endif // _di_kt_remove_flag_file_code_d_ /** diff --git a/sources/c/program/kevux/tools/remove/main/common/enumeration.h b/sources/c/program/kevux/tools/remove/main/common/enumeration.h index 3387966..a0289c2 100644 --- a/sources/c/program/kevux/tools/remove/main/common/enumeration.h +++ b/sources/c/program/kevux/tools/remove/main/common/enumeration.h @@ -22,6 +22,7 @@ extern "C" { #ifndef _di_kt_remove_parameter_e_ enum { kt_remove_parameter_accessed_e = f_console_standard_parameter_last_e, + kt_remove_parameter_allow_root_e, kt_remove_parameter_block_e, kt_remove_parameter_changed_e, kt_remove_parameter_character_e, @@ -54,36 +55,37 @@ extern "C" { { \ macro_fll_program_console_parameter_standard_initialize, \ \ - macro_f_console_parameter_t_initialize_3(kt_remove_short_accessed_s, kt_remove_long_accessed_s, 2, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(kt_remove_short_block_s, kt_remove_long_block_s, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(kt_remove_short_changed_s, kt_remove_long_changed_s, 2, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(kt_remove_short_character_s, kt_remove_long_character_s, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(kt_remove_short_different_s, kt_remove_long_different_s, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(kt_remove_short_directory_s, kt_remove_long_directory_s, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(kt_remove_short_empty_s, kt_remove_long_empty_s, 1, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(kt_remove_short_fifo_s, kt_remove_long_fifo_s, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(kt_remove_short_follow_s, kt_remove_long_follow_s, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(kt_remove_short_force_s, kt_remove_long_force_s, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(kt_remove_short_group_s, kt_remove_long_group_s, 1, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(kt_remove_short_link_s, kt_remove_long_link_s, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_5( kt_remove_long_local_s, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(kt_remove_short_mode_s, kt_remove_long_mode_s, 2, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(kt_remove_short_prompt_s, kt_remove_long_prompt_s, 1, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(kt_remove_short_recurse_s, kt_remove_long_recurse_s, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(kt_remove_short_regular_s, kt_remove_long_regular_s, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_5( kt_remove_long_remember_s, 1, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(kt_remove_short_same_s, kt_remove_long_same_s, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(kt_remove_short_simulate_s, kt_remove_long_simulate_s, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(kt_remove_short_socket_s, kt_remove_long_socket_s, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(kt_remove_short_stay_s, kt_remove_long_stay_s, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(kt_remove_short_tree_s, kt_remove_long_tree_s, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(kt_remove_short_updated_s, kt_remove_long_updated_s, 2, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(kt_remove_short_user_s, kt_remove_long_user_s, 1, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_5( kt_remove_long_unknown_s, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_5( kt_remove_long_utc_s, 0, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(kt_remove_short_accessed_s, kt_remove_long_accessed_s, 2, f_console_flag_normal_d), \ + macro_f_console_parameter_t_initialize_5( kt_remove_long_allow_root_s, 0, f_console_flag_normal_d), \ + macro_f_console_parameter_t_initialize_3(kt_remove_short_block_s, kt_remove_long_block_s, 0, f_console_flag_normal_d), \ + macro_f_console_parameter_t_initialize_3(kt_remove_short_changed_s, kt_remove_long_changed_s, 2, f_console_flag_normal_d), \ + macro_f_console_parameter_t_initialize_3(kt_remove_short_character_s, kt_remove_long_character_s, 0, f_console_flag_normal_d), \ + macro_f_console_parameter_t_initialize_3(kt_remove_short_different_s, kt_remove_long_different_s, 0, f_console_flag_normal_d), \ + macro_f_console_parameter_t_initialize_3(kt_remove_short_directory_s, kt_remove_long_directory_s, 0, f_console_flag_normal_d), \ + macro_f_console_parameter_t_initialize_3(kt_remove_short_empty_s, kt_remove_long_empty_s, 1, f_console_flag_normal_d), \ + macro_f_console_parameter_t_initialize_3(kt_remove_short_fifo_s, kt_remove_long_fifo_s, 0, f_console_flag_normal_d), \ + macro_f_console_parameter_t_initialize_3(kt_remove_short_follow_s, kt_remove_long_follow_s, 0, f_console_flag_normal_d), \ + macro_f_console_parameter_t_initialize_3(kt_remove_short_force_s, kt_remove_long_force_s, 0, f_console_flag_normal_d), \ + macro_f_console_parameter_t_initialize_3(kt_remove_short_group_s, kt_remove_long_group_s, 1, f_console_flag_normal_d), \ + macro_f_console_parameter_t_initialize_3(kt_remove_short_link_s, kt_remove_long_link_s, 0, f_console_flag_normal_d), \ + macro_f_console_parameter_t_initialize_5( kt_remove_long_local_s, 0, f_console_flag_normal_d), \ + macro_f_console_parameter_t_initialize_3(kt_remove_short_mode_s, kt_remove_long_mode_s, 2, f_console_flag_normal_d), \ + macro_f_console_parameter_t_initialize_3(kt_remove_short_prompt_s, kt_remove_long_prompt_s, 1, f_console_flag_normal_d), \ + macro_f_console_parameter_t_initialize_3(kt_remove_short_recurse_s, kt_remove_long_recurse_s, 0, f_console_flag_normal_d), \ + macro_f_console_parameter_t_initialize_3(kt_remove_short_regular_s, kt_remove_long_regular_s, 0, f_console_flag_normal_d), \ + macro_f_console_parameter_t_initialize_5( kt_remove_long_remember_s, 1, f_console_flag_normal_d), \ + macro_f_console_parameter_t_initialize_3(kt_remove_short_same_s, kt_remove_long_same_s, 0, f_console_flag_normal_d), \ + macro_f_console_parameter_t_initialize_3(kt_remove_short_simulate_s, kt_remove_long_simulate_s, 0, f_console_flag_normal_d), \ + macro_f_console_parameter_t_initialize_3(kt_remove_short_socket_s, kt_remove_long_socket_s, 0, f_console_flag_normal_d), \ + macro_f_console_parameter_t_initialize_3(kt_remove_short_stay_s, kt_remove_long_stay_s, 0, f_console_flag_normal_d), \ + macro_f_console_parameter_t_initialize_3(kt_remove_short_tree_s, kt_remove_long_tree_s, 0, f_console_flag_normal_d), \ + macro_f_console_parameter_t_initialize_3(kt_remove_short_updated_s, kt_remove_long_updated_s, 2, f_console_flag_normal_d), \ + macro_f_console_parameter_t_initialize_3(kt_remove_short_user_s, kt_remove_long_user_s, 1, f_console_flag_normal_d), \ + macro_f_console_parameter_t_initialize_5( kt_remove_long_unknown_s, 0, f_console_flag_normal_d), \ + macro_f_console_parameter_t_initialize_5( kt_remove_long_utc_s, 0, f_console_flag_normal_d), \ } - #define kt_remove_total_parameters_d (f_console_parameter_state_type_total_d + 27) + #define kt_remove_total_parameters_d (f_console_parameter_state_type_total_d + 28) #endif // _di_kt_remove_parameter_e_ #ifdef __cplusplus diff --git a/sources/c/program/kevux/tools/remove/main/common/print.c b/sources/c/program/kevux/tools/remove/main/common/print.c index 0a0c84b..60b247d 100644 --- a/sources/c/program/kevux/tools/remove/main/common/print.c +++ b/sources/c/program/kevux/tools/remove/main/common/print.c @@ -10,6 +10,7 @@ extern "C" { "f_console_parameter_process", "f_directory_remove", "f_file_exists", + "f_file_link_read", "f_file_mode_from_string", "f_file_mode_to_mode", "f_file_poll", @@ -25,8 +26,8 @@ extern "C" { "f_utf_is_whitespace", "fl_conversion_dynamic_partial_to_unsigned_detect", "fl_conversion_dynamic_to_unsigned_detect", + "fl_directory_do", "fl_path_clean", - "fl_recurse_do", "fll_program_parameter_process_context", "fll_program_parameter_process_empty", "fll_program_parameter_process_verbosity", diff --git a/sources/c/program/kevux/tools/remove/main/common/print.h b/sources/c/program/kevux/tools/remove/main/common/print.h index d8bda1e..b410ddd 100644 --- a/sources/c/program/kevux/tools/remove/main/common/print.h +++ b/sources/c/program/kevux/tools/remove/main/common/print.h @@ -43,6 +43,7 @@ extern "C" { kt_remove_f_f_console_parameter_process_e, kt_remove_f_f_directory_remove_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, kt_remove_f_f_file_mode_to_mode_e, kt_remove_f_f_file_poll_e, @@ -58,8 +59,8 @@ extern "C" { kt_remove_f_f_utf_is_whitespace_e, kt_remove_f_fl_conversion_dynamic_partial_to_unsigned_detect_e, kt_remove_f_fl_conversion_dynamic_to_unsigned_detect_e, + kt_remove_f_fl_directory_do_e, kt_remove_f_fl_path_clean_e, - kt_remove_f_fl_recurse_do_e, kt_remove_f_fll_program_parameter_process_context_e, kt_remove_f_fll_program_parameter_process_empty_e, kt_remove_f_fll_program_parameter_process_verbosity_e, diff --git a/sources/c/program/kevux/tools/remove/main/common/string.c b/sources/c/program/kevux/tools/remove/main/common/string.c index ca81329..75a81cf 100644 --- a/sources/c/program/kevux/tools/remove/main/common/string.c +++ b/sources/c/program/kevux/tools/remove/main/common/string.c @@ -23,6 +23,7 @@ extern "C" { const f_string_static_t kt_remove_never_s = macro_f_string_static_t_initialize_1(KT_REMOVE_never_s, 0, KT_REMOVE_never_s_length); const f_string_static_t kt_remove_no_s = macro_f_string_static_t_initialize_1(KT_REMOVE_no_s, 0, KT_REMOVE_no_s_length); const f_string_static_t kt_remove_not_s = macro_f_string_static_t_initialize_1(KT_REMOVE_not_s, 0, KT_REMOVE_not_s_length); + const f_string_static_t kt_remove_not_allowed_s = macro_f_string_static_t_initialize_1(KT_REMOVE_not_allowed_s, 0, KT_REMOVE_not_allowed_s_length); const f_string_static_t kt_remove_not_empty_s = macro_f_string_static_t_initialize_1(KT_REMOVE_not_empty_s, 0, KT_REMOVE_not_empty_s_length); const f_string_static_t kt_remove_not_fail_s = macro_f_string_static_t_initialize_1(KT_REMOVE_not_fail_s, 0, KT_REMOVE_not_fail_s_length); const f_string_static_t kt_remove_now_s = macro_f_string_static_t_initialize_1(KT_REMOVE_now_s, 0, KT_REMOVE_now_s_length); @@ -134,6 +135,7 @@ extern "C" { const f_string_static_t kt_remove_short_user_s = macro_f_string_static_t_initialize_1(KT_REMOVE_short_user_s, 0, KT_REMOVE_short_user_s_length); const f_string_static_t kt_remove_long_accessed_s = macro_f_string_static_t_initialize_1(KT_REMOVE_long_accessed_s, 0, KT_REMOVE_long_accessed_s_length); + const f_string_static_t kt_remove_long_allow_root_s = macro_f_string_static_t_initialize_1(KT_REMOVE_long_allow_root_s, 0, KT_REMOVE_long_allow_root_s_length); const f_string_static_t kt_remove_long_block_s = macro_f_string_static_t_initialize_1(KT_REMOVE_long_block_s, 0, KT_REMOVE_long_block_s_length); const f_string_static_t kt_remove_long_changed_s = macro_f_string_static_t_initialize_1(KT_REMOVE_long_changed_s, 0, KT_REMOVE_long_changed_s_length); const f_string_static_t kt_remove_long_character_s = macro_f_string_static_t_initialize_1(KT_REMOVE_long_character_s, 0, KT_REMOVE_long_character_s_length); diff --git a/sources/c/program/kevux/tools/remove/main/common/string.h b/sources/c/program/kevux/tools/remove/main/common/string.h index e4be189..3617c2a 100644 --- a/sources/c/program/kevux/tools/remove/main/common/string.h +++ b/sources/c/program/kevux/tools/remove/main/common/string.h @@ -69,63 +69,65 @@ extern "C" { * kt_remove_*_s: Arbitrary strings. */ #ifndef _di_kt_remove_s_ - #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" - #define KT_REMOVE_ignore_s "ignore" - #define KT_REMOVE_never_s "never" - #define KT_REMOVE_no_s "no" - #define KT_REMOVE_not_s "not" - #define KT_REMOVE_not_empty_s "not empty" - #define KT_REMOVE_not_fail_s "not_fail" - #define KT_REMOVE_now_s "now" - #define KT_REMOVE_once_s "once" - #define KT_REMOVE_only_s "only" - #define KT_REMOVE_only_fail_s "only_fail" - #define KT_REMOVE_parent_s "parent" - #define KT_REMOVE_prompt_s "prompt" - #define KT_REMOVE_recurse_s "recurse" - #define KT_REMOVE_remove_s "remove" - #define KT_REMOVE_root_s "root" - #define KT_REMOVE_same_s "same" - #define KT_REMOVE_today_s "today" - #define KT_REMOVE_tomorrow_s "tomorrow" - #define KT_REMOVE_tree_s "tree" - #define KT_REMOVE_yes_s "yes" - #define KT_REMOVE_yesterday_s "yesterday" - #define KT_REMOVE_user_s "user" - - #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 - #define KT_REMOVE_ignore_s_length 6 - #define KT_REMOVE_never_s_length 5 - #define KT_REMOVE_no_s_length 2 - #define KT_REMOVE_not_s_length 3 - #define KT_REMOVE_not_empty_s_length 9 - #define KT_REMOVE_not_fail_s_length 8 - #define KT_REMOVE_now_s_length 3 - #define KT_REMOVE_once_s_length 4 - #define KT_REMOVE_only_s_length 4 - #define KT_REMOVE_only_fail_s_length 9 - #define KT_REMOVE_parent_s_length 6 - #define KT_REMOVE_prompt_s_length 6 - #define KT_REMOVE_recurse_s_length 7 - #define KT_REMOVE_remove_s_length 6 - #define KT_REMOVE_root_s_length 4 - #define KT_REMOVE_same_s_length 4 - #define KT_REMOVE_today_s_length 5 - #define KT_REMOVE_tomorrow_s_length 8 - #define KT_REMOVE_tree_s_length 4 - #define KT_REMOVE_yes_s_length 3 - #define KT_REMOVE_yesterday_s_length 9 - #define KT_REMOVE_user_s_length 4 + #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" + #define KT_REMOVE_ignore_s "ignore" + #define KT_REMOVE_never_s "never" + #define KT_REMOVE_no_s "no" + #define KT_REMOVE_not_s "not" + #define KT_REMOVE_not_allowed_s "not allowed" + #define KT_REMOVE_not_empty_s "not empty" + #define KT_REMOVE_not_fail_s "not_fail" + #define KT_REMOVE_now_s "now" + #define KT_REMOVE_once_s "once" + #define KT_REMOVE_only_s "only" + #define KT_REMOVE_only_fail_s "only_fail" + #define KT_REMOVE_parent_s "parent" + #define KT_REMOVE_prompt_s "prompt" + #define KT_REMOVE_recurse_s "recurse" + #define KT_REMOVE_remove_s "remove" + #define KT_REMOVE_root_s "root" + #define KT_REMOVE_same_s "same" + #define KT_REMOVE_today_s "today" + #define KT_REMOVE_tomorrow_s "tomorrow" + #define KT_REMOVE_tree_s "tree" + #define KT_REMOVE_yes_s "yes" + #define KT_REMOVE_yesterday_s "yesterday" + #define KT_REMOVE_user_s "user" + + #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 + #define KT_REMOVE_ignore_s_length 6 + #define KT_REMOVE_never_s_length 5 + #define KT_REMOVE_no_s_length 2 + #define KT_REMOVE_not_s_length 3 + #define KT_REMOVE_not_allowed_s_length 11 + #define KT_REMOVE_not_empty_s_length 9 + #define KT_REMOVE_not_fail_s_length 8 + #define KT_REMOVE_now_s_length 3 + #define KT_REMOVE_once_s_length 4 + #define KT_REMOVE_only_s_length 4 + #define KT_REMOVE_only_fail_s_length 9 + #define KT_REMOVE_parent_s_length 6 + #define KT_REMOVE_prompt_s_length 6 + #define KT_REMOVE_recurse_s_length 7 + #define KT_REMOVE_remove_s_length 6 + #define KT_REMOVE_root_s_length 4 + #define KT_REMOVE_same_s_length 4 + #define KT_REMOVE_today_s_length 5 + #define KT_REMOVE_tomorrow_s_length 8 + #define KT_REMOVE_tree_s_length 4 + #define KT_REMOVE_yes_s_length 3 + #define KT_REMOVE_yesterday_s_length 9 + #define KT_REMOVE_user_s_length 4 extern const f_string_static_t kt_remove_each_s; extern const f_string_static_t kt_remove_empty_s; @@ -137,6 +139,7 @@ extern "C" { extern const f_string_static_t kt_remove_never_s; extern const f_string_static_t kt_remove_no_s; extern const f_string_static_t kt_remove_not_s; + extern const f_string_static_t kt_remove_not_allowed_s; extern const f_string_static_t kt_remove_not_empty_s; extern const f_string_static_t kt_remove_not_fail_s; extern const f_string_static_t kt_remove_now_s; @@ -429,33 +432,34 @@ extern "C" { #define KT_REMOVE_short_updated_s "U" #define KT_REMOVE_short_user_s "u" - #define KT_REMOVE_long_accessed_s "accessed" - #define KT_REMOVE_long_block_s "block" - #define KT_REMOVE_long_character_s "character" - #define KT_REMOVE_long_changed_s "changed" - #define KT_REMOVE_long_different_s "different" - #define KT_REMOVE_long_directory_s "directory" - #define KT_REMOVE_long_empty_s "empty" - #define KT_REMOVE_long_fifo_s "fifo" - #define KT_REMOVE_long_follow_s "follow" - #define KT_REMOVE_long_force_s "force" - #define KT_REMOVE_long_group_s "group" - #define KT_REMOVE_long_link_s "link" - #define KT_REMOVE_long_local_s "local" - #define KT_REMOVE_long_mode_s "mode" - #define KT_REMOVE_long_prompt_s "prompt" - #define KT_REMOVE_long_recurse_s "recurse" - #define KT_REMOVE_long_regular_s "regular" - #define KT_REMOVE_long_remember_s "remember" - #define KT_REMOVE_long_same_s "same" - #define KT_REMOVE_long_simulate_s "simulate" - #define KT_REMOVE_long_socket_s "socket" - #define KT_REMOVE_long_stay_s "stay" - #define KT_REMOVE_long_tree_s "tree" - #define KT_REMOVE_long_updated_s "updated" - #define KT_REMOVE_long_user_s "user" - #define KT_REMOVE_long_unknown_s "unknown" - #define KT_REMOVE_long_utc_s "utc" + #define KT_REMOVE_long_accessed_s "accessed" + #define KT_REMOVE_long_allow_root_s "allow_root" + #define KT_REMOVE_long_block_s "block" + #define KT_REMOVE_long_character_s "character" + #define KT_REMOVE_long_changed_s "changed" + #define KT_REMOVE_long_different_s "different" + #define KT_REMOVE_long_directory_s "directory" + #define KT_REMOVE_long_empty_s "empty" + #define KT_REMOVE_long_fifo_s "fifo" + #define KT_REMOVE_long_follow_s "follow" + #define KT_REMOVE_long_force_s "force" + #define KT_REMOVE_long_group_s "group" + #define KT_REMOVE_long_link_s "link" + #define KT_REMOVE_long_local_s "local" + #define KT_REMOVE_long_mode_s "mode" + #define KT_REMOVE_long_prompt_s "prompt" + #define KT_REMOVE_long_recurse_s "recurse" + #define KT_REMOVE_long_regular_s "regular" + #define KT_REMOVE_long_remember_s "remember" + #define KT_REMOVE_long_same_s "same" + #define KT_REMOVE_long_simulate_s "simulate" + #define KT_REMOVE_long_socket_s "socket" + #define KT_REMOVE_long_stay_s "stay" + #define KT_REMOVE_long_tree_s "tree" + #define KT_REMOVE_long_updated_s "updated" + #define KT_REMOVE_long_user_s "user" + #define KT_REMOVE_long_unknown_s "unknown" + #define KT_REMOVE_long_utc_s "utc" #define KT_REMOVE_short_accessed_s_length 1 #define KT_REMOVE_short_block_s_length 1 @@ -482,33 +486,34 @@ extern "C" { #define KT_REMOVE_short_updated_s_length 1 #define KT_REMOVE_short_user_s_length 1 - #define KT_REMOVE_long_accessed_s_length 8 - #define KT_REMOVE_long_block_s_length 6 - #define KT_REMOVE_long_character_s_length 9 - #define KT_REMOVE_long_changed_s_length 7 - #define KT_REMOVE_long_different_s_length 9 - #define KT_REMOVE_long_directory_s_length 9 - #define KT_REMOVE_long_empty_s_length 5 - #define KT_REMOVE_long_fifo_s_length 4 - #define KT_REMOVE_long_follow_s_length 6 - #define KT_REMOVE_long_force_s_length 5 - #define KT_REMOVE_long_group_s_length 5 - #define KT_REMOVE_long_link_s_length 4 - #define KT_REMOVE_long_local_s_length 5 - #define KT_REMOVE_long_mode_s_length 4 - #define KT_REMOVE_long_prompt_s_length 6 - #define KT_REMOVE_long_recurse_s_length 7 - #define KT_REMOVE_long_regular_s_length 7 - #define KT_REMOVE_long_remember_s_length 8 - #define KT_REMOVE_long_same_s_length 4 - #define KT_REMOVE_long_simulate_s_length 8 - #define KT_REMOVE_long_socket_s_length 6 - #define KT_REMOVE_long_stay_s_length 4 - #define KT_REMOVE_long_tree_s_length 4 - #define KT_REMOVE_long_updated_s_length 7 - #define KT_REMOVE_long_user_s_length 4 - #define KT_REMOVE_long_unknown_s_length 7 - #define KT_REMOVE_long_utc_s_length 3 + #define KT_REMOVE_long_accessed_s_length 8 + #define KT_REMOVE_long_allow_root_s_length 10 + #define KT_REMOVE_long_block_s_length 6 + #define KT_REMOVE_long_character_s_length 9 + #define KT_REMOVE_long_changed_s_length 7 + #define KT_REMOVE_long_different_s_length 9 + #define KT_REMOVE_long_directory_s_length 9 + #define KT_REMOVE_long_empty_s_length 5 + #define KT_REMOVE_long_fifo_s_length 4 + #define KT_REMOVE_long_follow_s_length 6 + #define KT_REMOVE_long_force_s_length 5 + #define KT_REMOVE_long_group_s_length 5 + #define KT_REMOVE_long_link_s_length 4 + #define KT_REMOVE_long_local_s_length 5 + #define KT_REMOVE_long_mode_s_length 4 + #define KT_REMOVE_long_prompt_s_length 6 + #define KT_REMOVE_long_recurse_s_length 7 + #define KT_REMOVE_long_regular_s_length 7 + #define KT_REMOVE_long_remember_s_length 8 + #define KT_REMOVE_long_same_s_length 4 + #define KT_REMOVE_long_simulate_s_length 8 + #define KT_REMOVE_long_socket_s_length 6 + #define KT_REMOVE_long_stay_s_length 4 + #define KT_REMOVE_long_tree_s_length 4 + #define KT_REMOVE_long_updated_s_length 7 + #define KT_REMOVE_long_user_s_length 4 + #define KT_REMOVE_long_unknown_s_length 7 + #define KT_REMOVE_long_utc_s_length 3 extern const f_string_static_t kt_remove_short_accessed_s; extern const f_string_static_t kt_remove_short_block_s; @@ -535,6 +540,7 @@ extern "C" { extern const f_string_static_t kt_remove_short_user_s; extern const f_string_static_t kt_remove_long_accessed_s; + extern const f_string_static_t kt_remove_long_allow_root_s; extern const f_string_static_t kt_remove_long_block_s; extern const f_string_static_t kt_remove_long_changed_s; extern const f_string_static_t kt_remove_long_character_s; diff --git a/sources/c/program/kevux/tools/remove/main/operate.c b/sources/c/program/kevux/tools/remove/main/operate.c index 5a060d4..6fcac43 100644 --- a/sources/c/program/kevux/tools/remove/main/operate.c +++ b/sources/c/program/kevux/tools/remove/main/operate.c @@ -7,7 +7,7 @@ extern "C" { #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) { - if (!kt_remove_operate_shall_remove(flag_operate)) return (flag_operate & kt_remove_flag_file_operate_remove_fail_d) ? F_status_set_error(F_no) : F_no; + if (!kt_remove_operate_shall_remove(flag_operate)) return (flag_operate & kt_remove_flag_file_operate_remove_fail_d) && !(main->setting.flag & kt_remove_main_flag_simulate_d) ? F_status_set_error(F_no) : F_no; // The recurse.state.code flags represent the top-level directory being recursed on. main->cache.recurse.state.code = (uint64_t) flag_operate; @@ -382,31 +382,26 @@ extern "C" { kt_remove_main_t * const main = (kt_remove_main_t *) recurse->state.custom; - // Arguments to fl_recurse_do() are invalid (parameter checking). - if (!recurse->depth) { - kt_remove_print_error_status(&main->program.error, macro_kt_remove_f(fl_recurse_do), recurse->state.status); - - return; - } + // 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)) { 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_recurse_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_directory_e, recurse->state.status); return; } // The top-level path is an empty string or an error occurred while processing the top-level path. if (!recurse->depth && (flag == f_directory_recurse_do_flag_path_d || flag == f_directory_recurse_do_flag_path_before_d)) { - kt_remove_print_error_file_status(&main->program.error, macro_kt_remove_f(fl_recurse_do), *recurse->path_top, f_file_operation_stat_s, fll_error_file_type_path_e, recurse->state.status); + kt_remove_print_error_file_status(&main->program.error, macro_kt_remove_f(fl_directory_do), *recurse->path_top, f_file_operation_stat_s, fll_error_file_type_path_e, recurse->state.status); return; } - // An error happened during directory list loading. - if (flag == f_directory_recurse_do_flag_path_list_d) { - kt_remove_print_error_file_status(&main->program.error, macro_kt_remove_f(fl_recurse_do), recurse->depth ? recurse->path : *recurse->path_top, f_file_operation_list_s, fll_error_file_type_directory_e, recurse->state.status); + if (recurse->state.status == F_status_set_error(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; } @@ -486,7 +481,7 @@ extern "C" { #ifndef _di_kt_remove_operate_shall_remove_ f_status_t kt_remove_operate_shall_remove(const uint32_t flag) { - return (flag & kt_remove_flag_file_operate_remove_d) && !(flag & kt_remove_flag_file_operate_remove_fail_d) && !(flag & kt_remove_flag_file_operate_remove_not_d); + return (flag & kt_remove_flag_file_operate_remove_d) && !(flag & kt_remove_flag_file_operate_remove_not_fail_d); } #endif // _di_kt_remove_operate_shall_remove_ diff --git a/sources/c/program/kevux/tools/remove/main/preprocess.c b/sources/c/program/kevux/tools/remove/main/preprocess.c index 154357d..8c987b3 100644 --- a/sources/c/program/kevux/tools/remove/main/preprocess.c +++ b/sources/c/program/kevux/tools/remove/main/preprocess.c @@ -19,10 +19,6 @@ extern "C" { uint32_t flag_out = (main->setting.flag & kt_remove_main_flag_option_type_used_d) ? 0 : kt_remove_flag_file_operate_remove_d; - uint8_t simulate = (main->setting.flag & kt_remove_main_flag_simulate_d) - ? kt_remove_flag_simulate_directory_not_d - : kt_remove_flag_simulate_none_d; - kt_remove_operate_memory_check(main, path, &flag_out); if (F_status_is_error(main->setting.state.status) || (flag_out & kt_remove_flag_file_operate_processed_d)) return flag_out; @@ -39,7 +35,7 @@ extern "C" { main->setting.state.status = f_file_is(path, F_file_type_link_d, F_false); if (F_status_is_error(main->setting.state.status)) { - kt_remove_print_simulate_operate_file(&main->program.output, simulate, path, flag_operate); + kt_remove_print_simulate_operate_file(&main->program.output, path, flag_operate); remove_print_warning_file_reason(&main->program.warning, path, kt_remove_print_reason_stat_fail_s); @@ -51,12 +47,12 @@ extern "C" { } } else if (exists == F_false || F_status_is_error(exists)) { - kt_remove_print_simulate_operate_file(&main->program.output, simulate, path, flag_operate); + kt_remove_print_simulate_operate_file(&main->program.output, path, flag_operate); - kt_remove_print_simulate_operate_file_exists(&main->program.output, simulate, path, flag_out, exists); + kt_remove_print_simulate_operate_file_exists(&main->program.output, path, flag_out, exists); if (exists == F_false) { - kt_remove_print_simulate_operate_boolean(&main->program.output, simulate, kt_remove_ignore_s, main->setting.flag & kt_remove_main_flag_force_d); + kt_remove_print_simulate_operate_boolean(&main->program.output, kt_remove_ignore_s, main->setting.flag & kt_remove_main_flag_force_d); return kt_remove_flag_file_operate_missing_d; } @@ -79,9 +75,9 @@ extern "C" { main->setting.state.status = f_file_stat(path, main->setting.flag & kt_remove_main_flag_follow_d, &statistics); if (F_status_is_error(main->setting.state.status)) { - kt_remove_print_simulate_operate_file(&main->program.output, simulate, path, flag_operate); + kt_remove_print_simulate_operate_file(&main->program.output, path, flag_operate); - kt_remove_print_simulate_operate_file_exists(&main->program.output, simulate, path, flag_out, F_false); + kt_remove_print_simulate_operate_file_exists(&main->program.output, path, flag_out, F_false); remove_print_warning_file_reason(&main->program.warning, path, kt_remove_print_reason_stat_fail_s); @@ -97,37 +93,36 @@ extern "C" { } } - // Directories get pre-processed before recursion to prevent unnecessary recursion but the pre-process again happens after recursion to perform actual operations because the child paths must be all be removed before the directory. - simulate = (main->setting.flag & kt_remove_main_flag_simulate_d) - ? (flag_out & kt_remove_flag_file_operate_directory_d) - ? recurse - ? kt_remove_flag_simulate_directory_recurse_d - : kt_remove_flag_simulate_directory_d - : kt_remove_flag_simulate_directory_not_d - : kt_remove_flag_simulate_none_d; + kt_remove_print_simulate_operate_file(&main->program.output, path, flag_operate); + + kt_remove_print_simulate_operate_file_exists(&main->program.output, path, flag_out, exists); + } - kt_remove_print_simulate_operate_file(&main->program.output, simulate, path, flag_operate); + 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); - kt_remove_print_simulate_operate_file_exists(&main->program.output, simulate, path, flag_out, exists); + flag_out |= kt_remove_flag_file_operate_remove_not_d; + } } - kt_remove_preprocess_file_type(main, kt_remove_flag_simulate_is_a_d | simulate, path, macro_f_file_type_is_block(statistics.st_mode), f_file_type_name_block_s, kt_remove_main_flag_block_d, kt_remove_main_flag_block_ignore_d, &flag_out); + kt_remove_preprocess_file_type(main, 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); - kt_remove_preprocess_file_type(main, kt_remove_flag_simulate_is_a_d | simulate, path, macro_f_file_type_is_character(statistics.st_mode), f_file_type_name_character_s, kt_remove_main_flag_character_d, kt_remove_main_flag_character_ignore_d, &flag_out); + kt_remove_preprocess_file_type(main, 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); - kt_remove_preprocess_file_type(main, kt_remove_flag_simulate_is_a_d | simulate, path, macro_f_file_type_is_directory(statistics.st_mode), f_file_type_name_directory_s, kt_remove_main_flag_directory_d, kt_remove_main_flag_directory_ignore_d, &flag_out); + 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 | simulate, path, macro_f_file_type_is_fifo(statistics.st_mode), f_file_type_name_fifo_s, kt_remove_main_flag_fifo_d, kt_remove_main_flag_fifo_ignore_d, &flag_out); + kt_remove_preprocess_file_type(main, kt_remove_flag_simulate_is_a_d, path, macro_f_file_type_is_fifo(statistics.st_mode), f_file_type_name_fifo_s, kt_remove_main_flag_fifo_d, kt_remove_main_flag_fifo_ignore_d, &flag_out); - kt_remove_preprocess_file_type(main, kt_remove_flag_simulate_is_a_d | simulate, path, macro_f_file_type_is_link(statistics.st_mode), f_file_type_name_link_s, kt_remove_main_flag_link_d, kt_remove_main_flag_link_ignore_d, &flag_out); + kt_remove_preprocess_file_type(main, kt_remove_flag_simulate_is_a_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_file_d | simulate, path, macro_f_file_type_is_regular(statistics.st_mode), f_file_type_name_regular_s, kt_remove_main_flag_regular_d, kt_remove_main_flag_regular_ignore_d, &flag_out); + kt_remove_preprocess_file_type(main, kt_remove_flag_simulate_is_a_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 | simulate, path, macro_f_file_type_is_socket(statistics.st_mode), f_file_type_name_socket_s, kt_remove_main_flag_socket_d, kt_remove_main_flag_socket_ignore_d, &flag_out); + kt_remove_preprocess_file_type(main, 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, simulate, path, macro_f_file_type_is_unknown(statistics.st_mode), f_file_type_name_unknown_s, kt_remove_main_flag_unknown_d, kt_remove_main_flag_unknown_ignore_d, &flag_out); + 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); - if (!simulate && (flag_out & kt_remove_flag_file_operate_remove_fail_d)) return flag_out; + if (!(main->setting.flag & kt_remove_main_flag_simulate_d) && (flag_out & kt_remove_flag_file_operate_remove_fail_d)) return flag_out; if (main->setting.flag & kt_remove_main_flag_user_d) { for (i = 0; i < main->setting.users.used; ++i) { @@ -136,9 +131,7 @@ extern "C" { if (statistics.st_uid == (uid_t) main->setting.users.array[i]) break; } // for - if (simulate & ~0x10) { - kt_remove_print_simulate_operate_id(&main->program.output, simulate, (f_number_unsigned_t) statistics.st_uid, F_true); - } + kt_remove_print_simulate_operate_id(&main->program.output, (f_number_unsigned_t) statistics.st_uid, F_true); if (i < main->setting.users.used) { flag_out |= kt_remove_flag_file_operate_remove_d; @@ -146,7 +139,7 @@ extern "C" { } if (main->setting.flag & kt_remove_main_flag_same_d) { - kt_remove_print_simulate_operate_boolean(&main->program.output, simulate, kt_remove_same_s, statistics.st_uid == geteuid()); + kt_remove_print_simulate_operate_boolean(&main->program.output, kt_remove_same_s, statistics.st_uid == geteuid()); if (statistics.st_uid == geteuid()) { flag_out |= kt_remove_flag_file_operate_remove_d; @@ -154,7 +147,7 @@ extern "C" { } if (main->setting.flag & kt_remove_main_flag_different_d) { - kt_remove_print_simulate_operate_boolean(&main->program.output, simulate, kt_remove_different_s, statistics.st_uid != geteuid()); + kt_remove_print_simulate_operate_boolean(&main->program.output, kt_remove_different_s, statistics.st_uid != geteuid()); if (statistics.st_uid != geteuid()) { flag_out |= kt_remove_flag_file_operate_remove_d; @@ -168,7 +161,7 @@ extern "C" { if (statistics.st_gid == (gid_t) main->setting.groups.array[i]) break; } // for - kt_remove_print_simulate_operate_id(&main->program.output, simulate, (f_number_unsigned_t) statistics.st_gid, F_false); + kt_remove_print_simulate_operate_id(&main->program.output, (f_number_unsigned_t) statistics.st_gid, F_false); if (i < main->setting.groups.used) { flag_out |= kt_remove_flag_file_operate_remove_d; @@ -192,7 +185,7 @@ extern "C" { kt_remove_flag_mode_not_d, }; - kt_remove_print_simulate_operate_mode(&main->program.output, simulate, (f_number_unsigned_t) mode, f_string_empty_s); + kt_remove_print_simulate_operate_mode(&main->program.output, (f_number_unsigned_t) mode, f_string_empty_s); for (i = 0; i < main->setting.modes.used; ++i) { @@ -216,7 +209,7 @@ extern "C" { for (uint8_t j = 0; j < 4; ++j) { if (main->setting.modes.array[i].type == types[j]) { - kt_remove_print_simulate_operate_mode(&main->program.output, simulate, (f_number_unsigned_t) main->setting.modes.array[i].mode, modes[j]); + kt_remove_print_simulate_operate_mode(&main->program.output, (f_number_unsigned_t) main->setting.modes.array[i].mode, modes[j]); break; } @@ -227,7 +220,7 @@ extern "C" { } if (main->setting.flag & kt_remove_main_flag_accessed_changed_updated_d) { - kt_remove_preprocess_file_dates(main, simulate, path, flag_operate, statistics); + kt_remove_preprocess_file_dates(main, path, flag_operate, statistics); if (F_status_is_error(main->setting.state.status)) return flag_out; if (main->setting.state.status == F_yes) { @@ -240,65 +233,67 @@ extern "C" { if (F_status_is_error(main->setting.state.status)) return flag_out; if (main->setting.state.status == F_true || main->setting.state.status == F_false) { - kt_remove_print_simulate_operate_boolean(&main->program.output, simulate, kt_remove_empty_s, main->setting.state.status); + kt_remove_print_simulate_operate_boolean(&main->program.output, kt_remove_empty_s, main->setting.state.status); if (main->setting.state.status == F_true) { flag_out |= kt_remove_flag_file_operate_empty_d; } - if (main->setting.flag & kt_remove_main_flag_empty_all_d) { - if (main->setting.state.status == F_true) { - 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_out & kt_remove_flag_file_operate_remove_not_d)) { + if (main->setting.flag & kt_remove_main_flag_empty_all_d) { + if (main->setting.state.status == F_true) { + 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_file_operate_remove_fail_d; + flag_out |= kt_remove_flag_file_operate_remove_fail_d; + } + else if (main->setting.flag & kt_remove_main_flag_empty_not_d) { + flag_out |= kt_remove_flag_file_operate_remove_not_d; + } } - else if (main->setting.flag & kt_remove_main_flag_empty_not_d) { - flag_out |= kt_remove_flag_file_operate_remove_not_d; + else if (main->setting.state.status == F_false) { + 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_out |= kt_remove_flag_file_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_file_operate_remove_not_d; + } } } else if (main->setting.state.status == F_false) { - if (main->setting.flag & kt_remove_main_flag_empty_only_fail_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_file_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_file_operate_remove_not_d; - } - } - } - else if (main->setting.state.status == F_false) { - 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_file_operate_remove_fail_d; } } } } if (flag_out & kt_remove_flag_file_operate_directory_d) { - kt_remove_print_simulate_operate_boolean(&main->program.output, simulate, kt_remove_recurse_s, (main->setting.flag & kt_remove_main_flag_recurse_d) && !(flag_operate & kt_remove_flag_file_operate_parent_d)); + kt_remove_print_simulate_operate_boolean(&main->program.output, kt_remove_recurse_s, (main->setting.flag & kt_remove_main_flag_recurse_d) && !(flag_operate & kt_remove_flag_file_operate_parent_d)); } if (main->setting.flag & kt_remove_main_flag_tree_d) { - kt_remove_print_simulate_operate_boolean(&main->program.output, simulate, kt_remove_parent_s, flag_operate & kt_remove_flag_file_operate_parent_d); + kt_remove_print_simulate_operate_boolean(&main->program.output, kt_remove_parent_s, flag_operate & kt_remove_flag_file_operate_parent_d); } if (main->setting.flag & kt_remove_main_flag_prompt_all_d) { if (main->setting.flag & (kt_remove_main_flag_prompt_each_d | kt_remove_main_flag_prompt_never_d)) { - kt_remove_print_simulate_operate_boolean(&main->program.output, simulate, kt_remove_prompt_s, main->setting.flag & kt_remove_main_flag_prompt_each_d); + kt_remove_print_simulate_operate_boolean(&main->program.output, 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, simulate, kt_remove_prompt_s, (main->setting.flag & kt_remove_main_flag_follow_d) && (flag_out & kt_remove_flag_file_operate_link_d)); + kt_remove_print_simulate_operate_boolean(&main->program.output, kt_remove_prompt_s, (main->setting.flag & kt_remove_main_flag_follow_d) && (flag_out & kt_remove_flag_file_operate_link_d)); } else if (main->setting.flag & kt_remove_main_flag_prompt_once_d) { - kt_remove_print_simulate_operate_boolean(&main->program.output, simulate, kt_remove_prompt_s, !(main->setting.prompt)); + kt_remove_print_simulate_operate_boolean(&main->program.output, kt_remove_prompt_s, !(main->setting.prompt)); } } - kt_remove_print_simulate_operate_boolean(&main->program.output, simulate, kt_remove_remove_s, kt_remove_operate_shall_remove(flag_out)); + kt_remove_print_simulate_operate_boolean(&main->program.output, kt_remove_remove_s, kt_remove_operate_shall_remove(flag_out)); // Only apply tree operations on non-child paths when the tree flag is set. if ((main->setting.flag & kt_remove_main_flag_tree_d) && !(flag_operate & kt_remove_flag_file_operate_child_d) && !recurse) { @@ -353,7 +348,7 @@ extern "C" { #endif // _di_kt_remove_preprocess_file_ #ifndef _di_kt_remove_preprocess_file_dates_ - void kt_remove_preprocess_file_dates(kt_remove_main_t * const main, const uint8_t simulate, const f_string_static_t path, const uint32_t flag_operate, const struct stat statistics) { + void kt_remove_preprocess_file_dates(kt_remove_main_t * const main, const f_string_static_t path, const uint32_t flag_operate, const struct stat statistics) { if (!main) return; @@ -599,7 +594,7 @@ extern "C" { } if (name_type.used) { - kt_remove_print_simulate_operate_date(&main->program.output, simulate, names[i], result, times[i], dates[i]->array[j], name_type); + kt_remove_print_simulate_operate_date(&main->program.output, names[i], result, times[i], dates[i]->array[j], name_type); break; } @@ -611,9 +606,9 @@ extern "C" { #endif // _di_kt_remove_preprocess_file_dates_ #ifndef _di_kt_remove_preprocess_file_type_ - void kt_remove_preprocess_file_type(kt_remove_main_t * const main, const uint8_t simulate, const f_string_static_t path, const bool is, f_string_static_t name, const uint64_t type, const uint64_t ignore, uint32_t * const flag_out) { + 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) { - if (!main || !flag_out) return; + if (!main) return; if (is) { if (main->setting.flag & type) { @@ -627,7 +622,7 @@ extern "C" { } if (is || (main->setting.flag & type) && !(main->setting.flag & ignore)) { - kt_remove_print_simulate_operate_boolean(&main->program.output, simulate & ~kt_remove_flag_simulate_is_a_file_d, name, is); + kt_remove_print_simulate_operate_boolean(&main->program.output, name, is); } } #endif // _di_kt_remove_preprocess_file_type_ diff --git a/sources/c/program/kevux/tools/remove/main/preprocess.h b/sources/c/program/kevux/tools/remove/main/preprocess.h index d9947d6..2cd6666 100644 --- a/sources/c/program/kevux/tools/remove/main/preprocess.h +++ b/sources/c/program/kevux/tools/remove/main/preprocess.h @@ -64,9 +64,6 @@ extern "C" { * F_yes on date matched. * F_no on no matches. * F_parameter (with error bit) if a parameter is invalid. - * @param simulate - * When non-zero, then this designates that the simulate printing should happen. - * When kt_remove_flag_simulate_directory_d, the printing is not performed. * @param path * The path to the file to operate on. * @param flag_operate @@ -75,7 +72,7 @@ extern "C" { * The already loaded file statistics. */ #ifndef _di_kt_remove_preprocess_file_dates_ - extern void kt_remove_preprocess_file_dates(kt_remove_main_t * const main, const uint8_t simulate, const f_string_static_t path, const uint32_t flag_operate, const struct stat statistics); + extern void kt_remove_preprocess_file_dates(kt_remove_main_t * const main, const f_string_static_t path, const uint32_t flag_operate, const struct stat statistics); #endif // _di_kt_remove_preprocess_file_dates_ /** @@ -114,7 +111,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 bool 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, uint32_t * const flag_out); #endif // _di_kt_remove_preprocess_file_type_ #ifdef __cplusplus diff --git a/sources/c/program/kevux/tools/remove/main/print/error.c b/sources/c/program/kevux/tools/remove/main/print/error.c index 94c57ed..cdfe691 100644 --- a/sources/c/program/kevux/tools/remove/main/print/error.c +++ b/sources/c/program/kevux/tools/remove/main/print/error.c @@ -18,6 +18,20 @@ extern "C" { } #endif // _di_kt_remove_print_error_ +#ifndef _di_kt_remove_print_error_file_ + f_status_t kt_remove_print_error_file(fl_print_t * const print, const f_string_t function, const f_string_static_t name, const f_string_static_t operation, const uint8_t type) { + + if (!print || !print->custom) return F_status_set_error(F_output_not); + if (print->verbosity < f_console_verbosity_error_e) return F_output_not; + + if (F_status_set_fine(((kt_remove_main_t *) print->custom)->setting.state.status) != F_interrupt) { + fll_error_file_print(print, F_status_set_fine(((kt_remove_main_t *) print->custom)->setting.state.status), function, F_true, name, operation, type); + } + + return F_okay; + } +#endif // _di_kt_remove_print_error_file_ + #ifndef _di_kt_remove_print_error_file_is_a_ f_status_t kt_remove_print_error_file_is_a(fl_print_t * const print, const f_string_static_t path, const f_string_static_t is, const uint8_t code) { @@ -52,20 +66,6 @@ extern "C" { } #endif // _di_kt_remove_print_error_file_is_a_ -#ifndef _di_kt_remove_print_error_file_ - f_status_t kt_remove_print_error_file(fl_print_t * const print, const f_string_t function, const f_string_static_t name, const f_string_static_t operation, const uint8_t type) { - - if (!print || !print->custom) return F_status_set_error(F_output_not); - if (print->verbosity < f_console_verbosity_error_e) return F_output_not; - - if (F_status_set_fine(((kt_remove_main_t *) print->custom)->setting.state.status) != F_interrupt) { - fll_error_file_print(print, F_status_set_fine(((kt_remove_main_t *) print->custom)->setting.state.status), function, F_true, name, operation, type); - } - - return F_okay; - } -#endif // _di_kt_remove_print_error_file_ - #ifndef _di_kt_remove_print_error_file_status_ f_status_t kt_remove_print_error_file_status(fl_print_t * const print, const f_string_t function, const f_string_static_t name, const f_string_static_t operation, const uint8_t type, const f_status_t status) { @@ -81,7 +81,7 @@ extern "C" { #endif // _di_kt_remove_print_error_file_status_ #ifndef _di_kt_remove_print_error_id_ - f_status_t kt_remove_print_error_id(fl_print_t * const print, const f_string_t function, const f_string_static_t name_id, const bool is_user) { + f_status_t kt_remove_print_error_id(fl_print_t * const print, const f_string_t function, const f_string_static_t name_id, const uint8_t is_user) { if (!print || !print->custom) return F_status_set_error(F_output_not); if (print->verbosity < f_console_verbosity_error_e) return F_output_not; diff --git a/sources/c/program/kevux/tools/remove/main/print/error.h b/sources/c/program/kevux/tools/remove/main/print/error.h index c20e5ba..7b8c841 100644 --- a/sources/c/program/kevux/tools/remove/main/print/error.h +++ b/sources/c/program/kevux/tools/remove/main/print/error.h @@ -160,7 +160,7 @@ extern "C" { * F_output_not (with error bit) if setting is NULL. */ #ifndef _di_kt_remove_print_error_id_ - extern f_status_t kt_remove_print_error_id(fl_print_t * const print, const f_string_t function, const f_string_static_t name_id, const bool is_user); + extern f_status_t kt_remove_print_error_id(fl_print_t * const print, const f_string_t function, const f_string_static_t name_id, const uint8_t is_user); #endif // _di_kt_remove_print_error_id_ /** diff --git a/sources/c/program/kevux/tools/remove/main/print/message.c b/sources/c/program/kevux/tools/remove/main/print/message.c index 7e9b89d..b53a6d9 100644 --- a/sources/c/program/kevux/tools/remove/main/print/message.c +++ b/sources/c/program/kevux/tools/remove/main/print/message.c @@ -51,10 +51,11 @@ extern "C" { f_print_dynamic_raw(f_string_eol_s, print->to); - fll_program_print_help_option_long(print, kt_remove_long_local_s, f_console_symbol_long_normal_s, " Designate dates are in local time, unless time zone is specified."); - fll_program_print_help_option_long(print, kt_remove_long_remember_s, f_console_symbol_long_normal_s, "Remember paths of files already deleted so as to not potentially error out on already removed path."); - fll_program_print_help_option_long(print, kt_remove_long_unknown_s, f_console_symbol_long_normal_s, " Remove by file type of unknown."); - fll_program_print_help_option_long(print, kt_remove_long_utc_s, f_console_symbol_long_normal_s, " Designate dates are in UTC, unless time zone is specified."); + fll_program_print_help_option_long(print, kt_remove_long_allow_root_s, f_console_symbol_long_normal_s, "Allow removal of the root directory '/'."); + fll_program_print_help_option_long(print, kt_remove_long_local_s, f_console_symbol_long_normal_s, " Designate dates are in local time, unless time zone is specified."); + fll_program_print_help_option_long(print, kt_remove_long_remember_s, f_console_symbol_long_normal_s, " Remember paths of files already deleted so as to not potentially error out on already removed path."); + fll_program_print_help_option_long(print, kt_remove_long_unknown_s, f_console_symbol_long_normal_s, " Remove by file type of unknown."); + fll_program_print_help_option_long(print, kt_remove_long_utc_s, f_console_symbol_long_normal_s, " Designate dates are in UTC, unless time zone is specified."); f_print_dynamic_raw(f_string_eol_s, print->to); diff --git a/sources/c/program/kevux/tools/remove/main/print/simulate.c b/sources/c/program/kevux/tools/remove/main/print/simulate.c index 88889b9..16b40cc 100644 --- a/sources/c/program/kevux/tools/remove/main/print/simulate.c +++ b/sources/c/program/kevux/tools/remove/main/print/simulate.c @@ -21,6 +21,8 @@ extern "C" { fl_print_format(" %Q%r", print->to, main->setting.files.array[i], f_string_eol_s); } // for + f_print_dynamic(f_string_eol_s, print->to); + f_file_stream_unlock(print->to); return F_okay; @@ -28,10 +30,13 @@ 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 uint8_t simulate, const f_string_static_t name, const bool yes) { + f_status_t kt_remove_print_simulate_operate_boolean(fl_print_t * const print, const f_string_static_t name, const uint8_t yes) { - if (!print) return F_status_set_error(F_output_not); - if (!simulate || (simulate & kt_remove_flag_simulate_directory_d)) return F_output_not; + if (!print || !print->custom) return F_status_set_error(F_output_not); + + kt_remove_main_t * const main = (kt_remove_main_t *) print->custom; + + if (!(main->setting.flag & kt_remove_main_flag_simulate_d)) return F_output_not; fll_print_format(" %r %r%r", print->to, name, yes ? kt_remove_yes_s : kt_remove_no_s, f_string_eol_s); @@ -40,10 +45,13 @@ 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 uint8_t simulate, const f_string_static_t name, const bool yes, const f_time_spec_t time, const kt_remove_date_t date, const f_string_static_t type) { + f_status_t kt_remove_print_simulate_operate_date(fl_print_t * const print, 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) return F_status_set_error(F_output_not); - if (!simulate || (simulate & kt_remove_flag_simulate_directory_d)) return F_output_not; + if (!print || !print->custom) return F_status_set_error(F_output_not); + + kt_remove_main_t * const main = (kt_remove_main_t *) print->custom; + + if (!(main->setting.flag & kt_remove_main_flag_simulate_d)) return F_output_not; const f_number_unsigned_t match_year = kt_remove_time_year_unix_epoch_d + (time.tv_sec / kt_remove_time_seconds_in_year_d); const f_number_unsigned_t match_second = time.tv_sec % kt_remove_time_seconds_in_year_d; @@ -64,10 +72,9 @@ 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 uint8_t simulate, const f_string_static_t path, const uint32_t flag) { + f_status_t kt_remove_print_simulate_operate_file(fl_print_t * const print, const f_string_static_t path, const uint32_t flag) { if (!print || !print->custom) return F_status_set_error(F_output_not); - if (!simulate || (simulate & kt_remove_flag_simulate_directory_d)) return F_output_not; kt_remove_main_t * const main = (kt_remove_main_t *) print->custom; @@ -90,10 +97,9 @@ extern "C" { #endif // _di_kt_remove_print_simulate_operate_file_ #ifndef _di_kt_remove_print_simulate_operate_file_exists_ - f_status_t kt_remove_print_simulate_operate_file_exists(fl_print_t * const print, const uint8_t simulate, const f_string_static_t path, const uint32_t flag, const f_status_t exists) { + f_status_t kt_remove_print_simulate_operate_file_exists(fl_print_t * const print, const f_string_static_t path, const uint32_t flag, const f_status_t exists) { if (!print || !print->custom) return F_status_set_error(F_output_not); - if (!simulate || (simulate & kt_remove_flag_simulate_directory_d)) return F_output_not; kt_remove_main_t * const main = (kt_remove_main_t *) print->custom; @@ -131,10 +137,9 @@ 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 uint8_t simulate, const f_number_unsigned_t id, const bool is_user) { + f_status_t kt_remove_print_simulate_operate_id(fl_print_t * const print, const f_number_unsigned_t id, const uint8_t is_user) { if (!print) return F_status_set_error(F_output_not); - if (!simulate || (simulate & kt_remove_flag_simulate_directory_d)) return F_output_not; fll_print_format(" %r %un%r", print->to, is_user ? kt_remove_user_s : kt_remove_group_s, id, f_string_eol_s); @@ -143,10 +148,9 @@ 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 uint8_t simulate, 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 f_number_unsigned_t mode, const f_string_static_t match) { if (!print) return F_status_set_error(F_output_not); - if (!simulate || (simulate & kt_remove_flag_simulate_directory_d)) return F_output_not; if (match.used) { fll_print_format(" mode_matched %Q %@03un%r", print->to, match, mode, f_string_eol_s); diff --git a/sources/c/program/kevux/tools/remove/main/print/simulate.h b/sources/c/program/kevux/tools/remove/main/print/simulate.h index 9ec1fcf..f31235e 100644 --- a/sources/c/program/kevux/tools/remove/main/print/simulate.h +++ b/sources/c/program/kevux/tools/remove/main/print/simulate.h @@ -53,9 +53,6 @@ extern "C" { * Must not be NULL. * * This does not alter print.custom.setting.state.status. - * @param simulate - * When non-zero, then this designates that the simulate printing should happen. - * When kt_remove_flag_simulate_directory_d, the printing is not performed. * @param name * The name to be associated with the boolean value. * @param yes @@ -69,7 +66,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 uint8_t simulate, const f_string_static_t name, const bool yes); + extern f_status_t kt_remove_print_simulate_operate_boolean(fl_print_t * const print, const f_string_static_t name, const uint8_t yes); #endif // _di_kt_remove_print_simulate_operate_boolean_ /** @@ -85,9 +82,6 @@ extern "C" { * Must not be NULL. * * This does not alter print.custom.setting.state.status. - * @param simulate - * When non-zero, then this designates that the simulate printing should happen. - * When kt_remove_flag_simulate_directory_d, the printing is not performed. * @param name * The name to be associated with the boolean value. * @param yes @@ -107,7 +101,7 @@ extern "C" { * F_output_not (with error bit) if setting is NULL. */ #ifndef _di_kt_remove_print_simulate_operate_date_ - extern f_status_t kt_remove_print_simulate_operate_date(fl_print_t * const print, const uint8_t simulate, const f_string_static_t name, const bool yes, const f_time_spec_t time, const kt_remove_date_t date, const f_string_static_t type); + extern f_status_t kt_remove_print_simulate_operate_date(fl_print_t * const print, 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_ /** @@ -123,9 +117,6 @@ extern "C" { * Must not be NULL. * * This does not alter print.custom.setting.state.status. - * @param simulate - * When non-zero, then this designates that the simulate printing should happen. - * When kt_remove_flag_simulate_directory_d, the printing is not performed. * @param path * The path to the file to operate on. * @param flag @@ -139,7 +130,7 @@ extern "C" { * F_output_not (with error bit) if setting is NULL. */ #ifndef _di_kt_remove_print_simulate_operate_file_ - extern f_status_t kt_remove_print_simulate_operate_file(fl_print_t * const print, const uint8_t simulate, const f_string_static_t path, const uint32_t flag); + extern f_status_t kt_remove_print_simulate_operate_file(fl_print_t * const print, const f_string_static_t path, const uint32_t flag); #endif // _di_kt_remove_print_simulate_operate_file_ /** @@ -155,9 +146,6 @@ extern "C" { * Must not be NULL. * * This does not alter print.custom.setting.state.status. - * @param simulate - * When non-zero, then this designates that the simulate printing should happen. - * When kt_remove_flag_simulate_directory_d, the printing is not performed. * @param path * The path to the file to operate on. * @param flag @@ -174,7 +162,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 uint8_t simulate, const f_string_static_t path, const uint32_t flag, const f_status_t exists); + extern f_status_t kt_remove_print_simulate_operate_file_exists(fl_print_t * const print, const f_string_static_t path, const uint32_t flag, const f_status_t exists); #endif // _di_kt_remove_print_simulate_operate_file_exists_ /** @@ -190,9 +178,6 @@ extern "C" { * Must not be NULL. * * This does not alter print.custom.setting.state.status. - * @param simulate - * When non-zero, then this designates that the simulate printing should happen. - * When kt_remove_flag_simulate_directory_d, the printing is not performed. * @param id * The user or group ID. * @param is_user @@ -206,7 +191,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 uint8_t simulate, const f_number_unsigned_t id, const bool is_user); + extern f_status_t kt_remove_print_simulate_operate_id(fl_print_t * const print, const f_number_unsigned_t id, const uint8_t is_user); #endif // _di_kt_remove_print_simulate_operate_id_ /** @@ -222,9 +207,6 @@ extern "C" { * Must not be NULL. * * This does not alter print.custom.setting.state.status. - * @param simulate - * When non-zero, then this designates that the simulate printing should happen. - * When kt_remove_flag_simulate_directory_d, the printing is not performed. * @param mode * The mode of the file. * @param match @@ -238,7 +220,7 @@ extern "C" { * F_output_not (with error bit) if setting is NULL. */ #ifndef _di_kt_remove_print_simulate_operate_mode_ - extern f_status_t kt_remove_print_simulate_operate_mode(fl_print_t * const print, const uint8_t simulate, 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 f_number_unsigned_t mode, const f_string_static_t match); #endif // _di_kt_remove_print_simulate_operate_mode_ #ifdef __cplusplus diff --git a/sources/c/program/kevux/tools/remove/rm/enumeration.h b/sources/c/program/kevux/tools/remove/rm/enumeration.h index eb8a669..4afbef6 100644 --- a/sources/c/program/kevux/tools/remove/rm/enumeration.h +++ b/sources/c/program/kevux/tools/remove/rm/enumeration.h @@ -33,27 +33,29 @@ extern "C" { kt_remove_rm_parameter_preserve_root_not_e, kt_remove_rm_parameter_verbose_alt_e, kt_remove_rm_parameter_version_alt_e, + kt_remove_rm_parameter_stop_e, }; // enum #define kt_remove_rm_console_parameter_t_initialize \ { \ macro_fll_program_console_parameter_standard_initialize, \ \ - macro_f_console_parameter_t_initialize_3(kt_remove_short_directory_s, kt_remove_rm_long_directory_s, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_4( kt_remove_rm_short_each_s, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(kt_remove_short_force_s, kt_remove_long_force_s, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_4( kt_remove_rm_short_once_s, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_5( kt_remove_rm_long_one_filesystem_s, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(kt_remove_short_recurse_s, kt_remove_long_recurse_s, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_4( kt_remove_rm_short_recursive_s, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(kt_remove_short_simulate_s, kt_remove_long_simulate_s, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_5( kt_remove_rm_long_preserve_root_s, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_5( kt_remove_rm_long_preserve_root_not_s, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(kt_remove_rm_short_verbose_s, kt_remove_rm_long_verbose_s, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_5( f_console_standard_long_version_s, 0, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(kt_remove_short_directory_s, kt_remove_rm_long_directory_s, 0, f_console_flag_normal_d), \ + macro_f_console_parameter_t_initialize_4( kt_remove_rm_short_each_s, 0, f_console_flag_normal_d), \ + macro_f_console_parameter_t_initialize_3(kt_remove_short_force_s, kt_remove_long_force_s, 0, f_console_flag_normal_d), \ + macro_f_console_parameter_t_initialize_4( kt_remove_rm_short_once_s, 0, f_console_flag_normal_d), \ + macro_f_console_parameter_t_initialize_5( kt_remove_rm_long_one_filesystem_s, 0, f_console_flag_normal_d), \ + macro_f_console_parameter_t_initialize_3(kt_remove_short_recurse_s, kt_remove_long_recurse_s, 0, f_console_flag_normal_d), \ + macro_f_console_parameter_t_initialize_4( kt_remove_rm_short_recursive_s, 0, f_console_flag_normal_d), \ + macro_f_console_parameter_t_initialize_3(kt_remove_short_simulate_s, kt_remove_long_simulate_s, 0, f_console_flag_normal_d), \ + macro_f_console_parameter_t_initialize_5( kt_remove_rm_long_preserve_root_s, 0, f_console_flag_normal_d), \ + macro_f_console_parameter_t_initialize_5( kt_remove_rm_long_preserve_root_not_s, 0, f_console_flag_normal_d), \ + macro_f_console_parameter_t_initialize_3(kt_remove_rm_short_verbose_s, kt_remove_rm_long_verbose_s, 0, f_console_flag_normal_d), \ + macro_f_console_parameter_t_initialize_5( f_console_standard_long_version_s, 0, f_console_flag_normal_d), \ + macro_f_console_parameter_t_initialize_7( 0, f_console_flag_normal_d | f_console_flag_empty_long_d | f_console_flag_stop_d), \ } - #define kt_remove_rm_total_parameters_d (f_console_parameter_state_type_total_d + 12) + #define kt_remove_rm_total_parameters_d (f_console_parameter_state_type_total_d + 13) #endif // _di_kt_remove_rm_parameter_e_ #ifdef __cplusplus diff --git a/sources/c/program/kevux/tools/remove/rm/rm.c b/sources/c/program/kevux/tools/remove/rm/rm.c index f1f8909..1e58e2e 100644 --- a/sources/c/program/kevux/tools/remove/rm/rm.c +++ b/sources/c/program/kevux/tools/remove/rm/rm.c @@ -11,6 +11,7 @@ extern "C" { f_number_unsigned_t argc = 0; + /* // Pre-process the parameters to find any "--" such that everything after the "--" represents a literal file name. if (arguments.argv) { for (argc = 1; argc < arguments.argc; ++argc) { @@ -25,27 +26,29 @@ extern "C" { } else { kt_remove_setting_load_standard(arguments, main); - } + }*/ + + kt_remove_setting_load_standard(arguments, main); if (F_status_is_error(main->setting.state.status)) return; - if (main->program.parameters.array[kt_remove_rm_parameter_directory_e].result & f_console_result_found_e) { + if (main->program.parameters.array[kt_remove_rm_parameter_directory_e].result & f_console_result_found_d) { main->setting.flag |= kt_remove_main_flag_directory_d | kt_remove_main_flag_empty_only_fail_d; } - if (main->program.parameters.array[kt_remove_rm_parameter_each_e].result & f_console_result_found_e) { + if (main->program.parameters.array[kt_remove_rm_parameter_each_e].result & f_console_result_found_d) { main->setting.flag |= kt_remove_main_flag_prompt_each_d; } - if (main->program.parameters.array[kt_remove_rm_parameter_force_e].result & f_console_result_found_e) { + if (main->program.parameters.array[kt_remove_rm_parameter_force_e].result & f_console_result_found_d) { main->setting.flag |= kt_remove_main_flag_force_d; } - if (main->program.parameters.array[kt_remove_rm_parameter_once_e].result & f_console_result_found_e) { + if (main->program.parameters.array[kt_remove_rm_parameter_once_e].result & f_console_result_found_d) { main->setting.flag |= kt_remove_main_flag_prompt_once_d; } - if (main->program.parameters.array[kt_remove_rm_parameter_one_filesystem_e].result & f_console_result_found_e) { + if (main->program.parameters.array[kt_remove_rm_parameter_one_filesystem_e].result & f_console_result_found_d) { main->setting.state.status = F_status_set_error(F_support_not); fll_program_print_error_parameter_support_not(&main->program.error, f_console_symbol_long_normal_s, kt_remove_rm_long_one_filesystem_s); @@ -53,27 +56,26 @@ extern "C" { return; } - if ((main->program.parameters.array[kt_remove_rm_parameter_recursive_e].result & f_console_result_found_e) || (main->program.parameters.array[kt_remove_rm_parameter_recursive_alt_e].result & f_console_result_found_e)) { + if ((main->program.parameters.array[kt_remove_rm_parameter_recursive_e].result & f_console_result_found_d) || (main->program.parameters.array[kt_remove_rm_parameter_recursive_alt_e].result & f_console_result_found_d)) { main->setting.flag |= kt_remove_main_flag_recurse_d | kt_remove_main_flag_directory_d; // Must not have the empty flags set while recursive. main->setting.flag &= ~kt_remove_main_flag_empty_all_d; } - // @todo the kt_remove_main_flag_root_d needs to be implemented in the base remove project. - if (main->program.parameters.array[kt_remove_rm_parameter_preserve_root_e].result & f_console_result_found_e) { - main->setting.flag &= ~kt_remove_main_flag_root_d; // @todo check if this or preserve_root_not is farther to the right. + if (main->program.parameters.array[kt_remove_rm_parameter_preserve_root_e].result & f_console_result_found_d) { + main->setting.flag &= ~kt_remove_main_flag_root_d; } - if (main->program.parameters.array[kt_remove_rm_parameter_preserve_root_not_e].result & f_console_result_found_e) { - main->setting.flag |= kt_remove_main_flag_root_d; // @todo check if this or preserve_root is farther to the right. + if (main->program.parameters.array[kt_remove_rm_parameter_preserve_root_not_e].result & f_console_result_found_d) { + main->setting.flag |= kt_remove_main_flag_root_d; } - if (main->program.parameters.array[kt_remove_rm_parameter_simulate_e].result & f_console_result_found_e) { + if (main->program.parameters.array[kt_remove_rm_parameter_simulate_e].result & f_console_result_found_d) { main->setting.flag |= kt_remove_main_flag_simulate_d; } - if (main->program.parameters.array[kt_remove_rm_parameter_verbose_alt_e].result & f_console_result_found_e) { + if (main->program.parameters.array[kt_remove_rm_parameter_verbose_alt_e].result & f_console_result_found_d) { main->program.warning.verbosity = main->program.error.verbosity = main->program.output.verbosity @@ -81,7 +83,7 @@ extern "C" { = f_console_verbosity_verbose_e; } - if (main->program.parameters.array[kt_remove_rm_parameter_version_alt_e].result & f_console_result_found_e) { + if (main->program.parameters.array[kt_remove_rm_parameter_version_alt_e].result & f_console_result_found_d) { main->setting.flag |= kt_remove_main_flag_version_d; } @@ -129,6 +131,7 @@ extern "C" { continue; } + // This is the default and "=all" is not supported, so ignore this parameter. if (f_compare_dynamic(kt_remove_rm_static_preserve_root_all_s, main->program.parameters.arguments.array[index]) == F_equal_to) { main->setting.state.status = F_status_set_error(F_support_not); @@ -137,7 +140,6 @@ extern "C" { return; } - // This is the default and "=all" is not supported, so ignore this parameter. if (f_compare_dynamic(kt_remove_rm_static_preserve_root_slash_s, main->program.parameters.arguments.array[index]) == F_equal_to) { continue; } @@ -155,24 +157,6 @@ extern "C" { ++main->setting.files.used; } // for } - - if (argc < arguments.argc) { - f_string_static_t args = f_string_static_t_initialize; - - for (++argc; argc < arguments.argc; ++argc, ++main->setting.files.used) { - - args.string = arguments.argv[argc]; - args.used = strnlen(arguments.argv[argc], F_console_parameter_size_d); - - fl_path_clean(args, &main->setting.files.array[main->setting.files.used]); - - if (F_status_is_error(main->setting.state.status)) { - kt_remove_print_error_file(&main->program.error, macro_kt_remove_f(fl_path_clean), args, f_file_operation_process_s, fll_error_file_type_path_e); - - return; - } - } // for - } } // Make sure all non-directory files are deleted. diff --git a/sources/c/program/kevux/tools/remove/rmdir/enumeration.h b/sources/c/program/kevux/tools/remove/rmdir/enumeration.h index 393f939..a4aedb5 100644 --- a/sources/c/program/kevux/tools/remove/rmdir/enumeration.h +++ b/sources/c/program/kevux/tools/remove/rmdir/enumeration.h @@ -32,11 +32,11 @@ extern "C" { { \ macro_fll_program_console_parameter_standard_initialize, \ \ - macro_f_console_parameter_t_initialize_5( kt_remove_rmdir_long_ignore_empty_not_s, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(kt_remove_rmdir_short_parents_s, kt_remove_rmdir_long_parents_s, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(kt_remove_short_simulate_s, kt_remove_long_simulate_s, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(f_console_standard_short_verbose_s, f_console_standard_long_verbose_s, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_5( f_console_standard_long_version_s, 0, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_5( kt_remove_rmdir_long_ignore_empty_not_s, 0, f_console_flag_normal_d), \ + macro_f_console_parameter_t_initialize_3(kt_remove_rmdir_short_parents_s, kt_remove_rmdir_long_parents_s, 0, f_console_flag_normal_d), \ + macro_f_console_parameter_t_initialize_3(kt_remove_short_simulate_s, kt_remove_long_simulate_s, 0, f_console_flag_normal_d), \ + macro_f_console_parameter_t_initialize_3(f_console_standard_short_verbose_s, f_console_standard_long_verbose_s, 0, f_console_flag_normal_d), \ + macro_f_console_parameter_t_initialize_5( f_console_standard_long_version_s, 0, f_console_flag_normal_d), \ } #define kt_remove_rmdir_total_parameters_d (f_console_parameter_state_type_total_d + 5) diff --git a/sources/c/program/kevux/tools/remove/rmdir/rmdir.c b/sources/c/program/kevux/tools/remove/rmdir/rmdir.c index e4fc58a..4e2930b 100644 --- a/sources/c/program/kevux/tools/remove/rmdir/rmdir.c +++ b/sources/c/program/kevux/tools/remove/rmdir/rmdir.c @@ -12,19 +12,19 @@ extern "C" { kt_remove_setting_load_standard(arguments, main); if (F_status_is_error(main->setting.state.status)) return; - if (main->program.parameters.array[kt_remove_rmdir_parameter_ignore_empty_not_e].result & f_console_result_found_e) { + if (main->program.parameters.array[kt_remove_rmdir_parameter_ignore_empty_not_e].result & f_console_result_found_d) { main->setting.flag |= kt_remove_main_flag_empty_only_d; } - if (main->program.parameters.array[kt_remove_rmdir_parameter_parents_e].result & f_console_result_found_e) { + if (main->program.parameters.array[kt_remove_rmdir_parameter_parents_e].result & f_console_result_found_d) { main->setting.flag |= kt_remove_main_flag_tree_d; } - if (main->program.parameters.array[kt_remove_rmdir_parameter_simulate_e].result & f_console_result_found_e) { + if (main->program.parameters.array[kt_remove_rmdir_parameter_simulate_e].result & f_console_result_found_d) { main->setting.flag |= kt_remove_main_flag_simulate_d; } - if (main->program.parameters.array[kt_remove_rmdir_parameter_verbose_alt_e].result & f_console_result_found_e) { + if (main->program.parameters.array[kt_remove_rmdir_parameter_verbose_alt_e].result & f_console_result_found_d) { main->program.warning.verbosity = main->program.error.verbosity = main->program.output.verbosity @@ -32,37 +32,11 @@ extern "C" { = f_console_verbosity_verbose_e; } - if (main->program.parameters.array[kt_remove_rmdir_parameter_version_alt_e].result & f_console_result_found_e) { + if (main->program.parameters.array[kt_remove_rmdir_parameter_version_alt_e].result & f_console_result_found_d) { main->setting.flag |= kt_remove_main_flag_version_d; } - // Load all remaining files as static strings (setting size to 0). - if (main->program.parameters.remaining.used) { - main->setting.state.status = f_memory_array_increase_by(main->program.parameters.remaining.used, sizeof(f_string_dynamic_t), (void **) &main->setting.files.array, &main->setting.files.used, &main->setting.files.size); - - if (F_status_is_error(main->setting.state.status)) { - kt_remove_print_error(&main->program.error, macro_kt_remove_f(f_memory_array_increase_by)); - - return; - } - - f_number_unsigned_t index = 0; - - for (f_number_unsigned_t i = 0; i < main->program.parameters.remaining.used; ++i, ++main->setting.files.used) { - - index = main->program.parameters.remaining.array[i]; - - main->setting.files.array[main->setting.files.used].used = 0; - - fl_path_clean(main->program.parameters.arguments.array[index], &main->setting.files.array[main->setting.files.used]); - - if (F_status_is_error(main->setting.state.status)) { - kt_remove_print_error_file(&main->program.error, macro_kt_remove_f(fl_path_clean), main->program.parameters.arguments.array[index], f_file_operation_process_s, fll_error_file_type_path_e); - - return; - } - } // for - } + kt_remove_setting_load_remaining(arguments, main); // Make sure only directoreis are deleted. main->setting.flag |= kt_remove_main_flag_directory_d | kt_remove_main_flag_option_type_d | kt_remove_main_flag_option_used_d; diff --git a/sources/c/program/kevux/tools/remove/unlink/enumeration.h b/sources/c/program/kevux/tools/remove/unlink/enumeration.h index 2fafd1f..f6a79b7 100644 --- a/sources/c/program/kevux/tools/remove/unlink/enumeration.h +++ b/sources/c/program/kevux/tools/remove/unlink/enumeration.h @@ -29,8 +29,8 @@ extern "C" { { \ macro_fll_program_console_parameter_standard_initialize, \ \ - macro_f_console_parameter_t_initialize_3(kt_remove_short_simulate_s, kt_remove_long_simulate_s, 0, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_5( f_console_standard_long_version_s, 0, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(kt_remove_short_simulate_s, kt_remove_long_simulate_s, 0, f_console_flag_normal_d), \ + macro_f_console_parameter_t_initialize_5( f_console_standard_long_version_s, 0, f_console_flag_normal_d), \ } #define kt_remove_unlink_total_parameters_d (f_console_parameter_state_type_total_d + 1) diff --git a/sources/c/program/kevux/tools/remove/unlink/unlink.c b/sources/c/program/kevux/tools/remove/unlink/unlink.c index 05765c6..d848b69 100644 --- a/sources/c/program/kevux/tools/remove/unlink/unlink.c +++ b/sources/c/program/kevux/tools/remove/unlink/unlink.c @@ -12,37 +12,11 @@ extern "C" { kt_remove_setting_load_standard(arguments, main); if (F_status_is_error(main->setting.state.status)) return; - if (main->program.parameters.array[kt_remove_unlink_parameter_simulate_e].result & f_console_result_found_e) { + if (main->program.parameters.array[kt_remove_unlink_parameter_simulate_e].result & f_console_result_found_d) { main->setting.flag |= kt_remove_main_flag_simulate_d; } - // Load all remaining files as static strings (setting size to 0). - if (main->program.parameters.remaining.used) { - main->setting.state.status = f_memory_array_increase_by(main->program.parameters.remaining.used, sizeof(f_string_dynamic_t), (void **) &main->setting.files.array, &main->setting.files.used, &main->setting.files.size); - - if (F_status_is_error(main->setting.state.status)) { - kt_remove_print_error(&main->program.error, macro_kt_remove_f(f_memory_array_increase_by)); - - return; - } - - f_number_unsigned_t index = 0; - - for (f_number_unsigned_t i = 0; i < main->program.parameters.remaining.used; ++i, ++main->setting.files.used) { - - index = main->program.parameters.remaining.array[i]; - - main->setting.files.array[main->setting.files.used].used = 0; - - fl_path_clean(main->program.parameters.arguments.array[index], &main->setting.files.array[main->setting.files.used]); - - if (F_status_is_error(main->setting.state.status)) { - kt_remove_print_error_file(&main->program.error, macro_kt_remove_f(fl_path_clean), main->program.parameters.arguments.array[index], f_file_operation_process_s, fll_error_file_type_path_e); - - return; - } - } // for - } + kt_remove_setting_load_remaining(arguments, main); // Make sure only links are deleted. main->setting.flag |= kt_remove_main_flag_link_d | kt_remove_main_flag_option_type_d | kt_remove_main_flag_option_used_d; diff --git a/sources/c/program/kevux/tools/tacocat/main/common.c b/sources/c/program/kevux/tools/tacocat/main/common.c index 0eb975a..af50bb5 100644 --- a/sources/c/program/kevux/tools/tacocat/main/common.c +++ b/sources/c/program/kevux/tools/tacocat/main/common.c @@ -61,33 +61,33 @@ extern "C" { f_number_unsigned_t index = 0; - if (main->program.parameters.array[kt_tacocat_parameter_help_e].result & f_console_result_found_e) { + if (main->program.parameters.array[kt_tacocat_parameter_help_e].result & f_console_result_found_d) { main->setting.flag |= kt_tacocat_main_flag_help_d; } else { main->setting.flag &= ~kt_tacocat_main_flag_help_d; } - if (main->program.parameters.array[kt_tacocat_parameter_version_e].result & f_console_result_found_e) { + if (main->program.parameters.array[kt_tacocat_parameter_version_e].result & f_console_result_found_d) { main->setting.flag |= kt_tacocat_main_flag_version_d; } else { main->setting.flag &= ~kt_tacocat_main_flag_version_d; } - if (main->program.parameters.array[kt_tacocat_parameter_copyright_e].result & f_console_result_found_e) { + if (main->program.parameters.array[kt_tacocat_parameter_copyright_e].result & f_console_result_found_d) { main->setting.flag |= kt_tacocat_main_flag_copyright_d; } else { main->setting.flag &= ~kt_tacocat_main_flag_copyright_d; } - if (main->program.parameters.array[kt_tacocat_parameter_resolve_e].result & f_console_result_found_e) { + if (main->program.parameters.array[kt_tacocat_parameter_resolve_e].result & f_console_result_found_d) { main->setting.state.status = F_status_set_error(F_parameter); fll_program_print_error_parameter_missing_value(&main->program.error, f_console_symbol_long_normal_s, kt_tacocat_long_resolve_s); } - else if (main->program.parameters.array[kt_tacocat_parameter_resolve_e].result & f_console_result_value_e) { + else if (main->program.parameters.array[kt_tacocat_parameter_resolve_e].result & f_console_result_value_d) { index = main->program.parameters.array[kt_tacocat_parameter_resolve_e].values.array[main->program.parameters.array[kt_tacocat_parameter_resolve_e].values.used - 1]; if (f_compare_dynamic(main->program.parameters.arguments.array[index], kt_tacocat_classic_s) == F_equal_to) { @@ -114,7 +114,7 @@ extern "C" { #endif // _kt_resolve_default_kevux_ } - if (main->program.parameters.array[kt_tacocat_parameter_interval_e].result & f_console_result_value_e) { + if (main->program.parameters.array[kt_tacocat_parameter_interval_e].result & f_console_result_value_d) { index = main->program.parameters.array[kt_tacocat_parameter_interval_e].values.array[main->program.parameters.array[kt_tacocat_parameter_interval_e].values.used - 1]; f_number_unsigned_t number = 0; @@ -141,7 +141,7 @@ extern "C" { main->setting.interval_fast = number; } } - else if (main->program.parameters.array[kt_tacocat_parameter_interval_e].result & f_console_result_found_e) { + else if (main->program.parameters.array[kt_tacocat_parameter_interval_e].result & f_console_result_found_d) { main->setting.state.status = F_status_set_error(F_parameter); fll_program_print_error_parameter_missing_value(&main->program.error, f_console_symbol_long_normal_s, kt_tacocat_long_interval_s); @@ -149,7 +149,7 @@ extern "C" { return; } - if (main->program.parameters.array[kt_tacocat_parameter_max_buffer_e].result & f_console_result_value_e) { + if (main->program.parameters.array[kt_tacocat_parameter_max_buffer_e].result & f_console_result_value_d) { index = main->program.parameters.array[kt_tacocat_parameter_max_buffer_e].values.array[main->program.parameters.array[kt_tacocat_parameter_max_buffer_e].values.used - 1]; f_number_unsigned_t number = 0; @@ -186,7 +186,7 @@ extern "C" { main->setting.flag |= kt_tacocat_main_flag_max_buffer_d; } } - else if (main->program.parameters.array[kt_tacocat_parameter_max_buffer_e].result & f_console_result_found_e) { + else if (main->program.parameters.array[kt_tacocat_parameter_max_buffer_e].result & f_console_result_found_d) { main->setting.state.status = F_status_set_error(F_parameter); fll_program_print_error_parameter_missing_value(&main->program.error, f_console_symbol_long_normal_s, kt_tacocat_long_max_buffer_s); @@ -235,7 +235,7 @@ extern "C" { &main->setting.send_polls, }; - const bool is_receive[] = { + const uint8_t is_receive[] = { F_true, F_false, }; @@ -264,7 +264,7 @@ extern "C" { for (uint8_t i = 0; i < 2; ++i) { - if (main->program.parameters.array[parameters[i]].result & f_console_result_value_e) { + if (main->program.parameters.array[parameters[i]].result & f_console_result_value_d) { main->setting.flag |= flags[i]; if (main->program.parameters.array[parameters[i]].values.used % 2) { @@ -572,7 +572,7 @@ extern "C" { } } // for } - else if (main->program.parameters.array[parameters[i]].result & f_console_result_found_e) { + else if (main->program.parameters.array[parameters[i]].result & f_console_result_found_d) { main->setting.flag &= ~flags[i]; main->setting.state.status = F_status_set_error(F_parameter); diff --git a/sources/c/program/kevux/tools/tacocat/main/common/enumeration.h b/sources/c/program/kevux/tools/tacocat/main/common/enumeration.h index eecef55..8723db3 100644 --- a/sources/c/program/kevux/tools/tacocat/main/common/enumeration.h +++ b/sources/c/program/kevux/tools/tacocat/main/common/enumeration.h @@ -44,11 +44,11 @@ extern "C" { { \ macro_fll_program_console_parameter_standard_initialize, \ \ - macro_f_console_parameter_t_initialize_3(kt_tacocat_short_interval_s, kt_tacocat_long_interval_s, 1, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(kt_tacocat_short_max_buffer_s, kt_tacocat_long_max_buffer_s, 1, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(kt_tacocat_short_receive_s, kt_tacocat_long_receive_s, 2, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(kt_tacocat_short_resolve_s, kt_tacocat_long_resolve_s, 1, f_console_flag_normal_e), \ - macro_f_console_parameter_t_initialize_3(kt_tacocat_short_send_s, kt_tacocat_long_send_s, 2, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(kt_tacocat_short_interval_s, kt_tacocat_long_interval_s, 1, f_console_flag_normal_d), \ + macro_f_console_parameter_t_initialize_3(kt_tacocat_short_max_buffer_s, kt_tacocat_long_max_buffer_s, 1, f_console_flag_normal_d), \ + macro_f_console_parameter_t_initialize_3(kt_tacocat_short_receive_s, kt_tacocat_long_receive_s, 2, f_console_flag_normal_d), \ + macro_f_console_parameter_t_initialize_3(kt_tacocat_short_resolve_s, kt_tacocat_long_resolve_s, 1, f_console_flag_normal_d), \ + macro_f_console_parameter_t_initialize_3(kt_tacocat_short_send_s, kt_tacocat_long_send_s, 2, f_console_flag_normal_d), \ } #define kt_tacocat_parameter_total_d (f_console_parameter_state_type_total_d + 5) diff --git a/sources/c/program/kevux/tools/tacocat/main/send.c b/sources/c/program/kevux/tools/tacocat/main/send.c index b41711d..ce6f2bd 100644 --- a/sources/c/program/kevux/tools/tacocat/main/send.c +++ b/sources/c/program/kevux/tools/tacocat/main/send.c @@ -14,7 +14,7 @@ extern "C" { kt_tacocat_main_t * const main = (kt_tacocat_main_t *) void_main; f_number_unsigned_t i = 0; f_status_t ready = F_okay; - bool poll = F_false; + uint8_t poll = F_false; kt_tacocat_process_socket_set_send(main); diff --git a/tests/unit/remove/c/mock-remove.c b/tests/unit/remove/c/mock-remove.c index b3cb053..bc9b73b 100644 --- a/tests/unit/remove/c/mock-remove.c +++ b/tests/unit/remove/c/mock-remove.c @@ -35,15 +35,15 @@ f_status_t __wrap_f_directory_empty(const f_string_static_t path) { return mock_type(f_status_t); } -f_status_t __wrap_f_directory_remove(const f_string_static_t path, const int depth_max, const bool preserve) { +f_status_t __wrap_f_directory_remove(const f_string_static_t path, const int depth_max, const uint8_t preserve) { return mock_type(f_status_t); } -f_status_t __wrap_f_file_exists(const f_string_static_t path, const bool dereference) { +f_status_t __wrap_f_file_exists(const f_string_static_t path, const uint8_t dereference) { return mock_type(f_status_t); } -f_status_t __wrap_f_file_is(const f_string_static_t path, const int type, const bool dereference) { +f_status_t __wrap_f_file_is(const f_string_static_t path, const int type, const uint8_t dereference) { return mock_type(f_status_t); } @@ -51,7 +51,7 @@ f_status_t __wrap_f_file_remove(const f_string_static_t path) { return mock_type(f_status_t); } -f_status_t __wrap_f_file_stat(const f_string_static_t path, const bool dereference, struct stat * const stat_file) { +f_status_t __wrap_f_file_stat(const f_string_static_t path, const uint8_t dereference, struct stat * const stat_file) { struct stat * const mocked_stat = mock_ptr_type(struct stat *); diff --git a/tests/unit/remove/c/mock-remove.h b/tests/unit/remove/c/mock-remove.h index 2ee899a..5f555d4 100644 --- a/tests/unit/remove/c/mock-remove.h +++ b/tests/unit/remove/c/mock-remove.h @@ -42,12 +42,12 @@ extern f_status_t __wrap_f_account_group_id_by_name(const f_string_static_t name extern f_status_t __wrap_f_account_id_by_name(const f_string_static_t name, f_uid_t * const id); 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 bool preserve); +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_exists(const f_string_static_t path, const bool dereference); -extern f_status_t __wrap_f_file_is(const f_string_static_t path, const int type, const bool dereference); +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); -extern f_status_t __wrap_f_file_stat(const f_string_static_t path, const bool dereference, struct stat * const stat_file); +extern f_status_t __wrap_f_file_stat(const f_string_static_t path, const uint8_t dereference, struct stat * const stat_file); extern f_status_t __wrap_f_time_clock_get(const clockid_t code, f_time_spec_t * const time); diff --git a/tests/unit/remove/c/test-remove-date_accessed.c b/tests/unit/remove/c/test-remove-date_accessed.c index 9321cb4..0abadb1 100644 --- a/tests/unit/remove/c/test-remove-date_accessed.c +++ b/tests/unit/remove/c/test-remove-date_accessed.c @@ -91,7 +91,7 @@ void test__kt_remove__date_accessed__date_works(void **state) { macro_f_time_spec_t_initialize_1(1672429502, 0), }; - bool time_spec_removes[] = { + uint8_t time_spec_removes[] = { F_false, // Equal F_false, F_false, @@ -139,8 +139,17 @@ void test__kt_remove__date_accessed__date_works(void **state) { if (time_spec_removes[date]) { if (macro_f_file_type_is_directory(stats[type].st_mode)) { - will_return(__wrap_fl_directory_do, 0); - will_return(__wrap_fl_directory_do, F_okay); + will_return(__wrap_fl_directory_do, 1); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_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(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); } @@ -239,7 +248,7 @@ void test__kt_remove__date_accessed__now_works(void **state) { const f_time_spec_t time_spec_clocks = macro_f_time_spec_t_initialize_1(2 * 86400, 123); - bool time_spec_removes[] = { + uint8_t time_spec_removes[] = { F_true, // Equal F_false, F_false, @@ -293,8 +302,17 @@ void test__kt_remove__date_accessed__now_works(void **state) { if (time_spec_removes[date]) { if (macro_f_file_type_is_directory(stats[type].st_mode)) { - will_return(__wrap_fl_directory_do, 0); - will_return(__wrap_fl_directory_do, F_okay); + will_return(__wrap_fl_directory_do, 1); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_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(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); } @@ -392,7 +410,7 @@ void test__kt_remove__date_accessed__today_works(void **state) { const f_time_spec_t time_spec_clocks = macro_f_time_spec_t_initialize_1(2 * 86400, 123); - bool time_spec_removes[] = { + uint8_t time_spec_removes[] = { F_true, // Equal F_true, F_false, @@ -446,8 +464,17 @@ void test__kt_remove__date_accessed__today_works(void **state) { if (time_spec_removes[date]) { if (macro_f_file_type_is_directory(stats[type].st_mode)) { - will_return(__wrap_fl_directory_do, 0); - will_return(__wrap_fl_directory_do, F_okay); + will_return(__wrap_fl_directory_do, 1); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_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(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); } @@ -545,7 +572,7 @@ void test__kt_remove__date_accessed__tomorrow_works(void **state) { const f_time_spec_t time_spec_clocks = macro_f_time_spec_t_initialize_1(2 * 86400, 123); - bool time_spec_removes[] = { + uint8_t time_spec_removes[] = { F_false, // Equal F_false, F_true, @@ -599,8 +626,17 @@ void test__kt_remove__date_accessed__tomorrow_works(void **state) { if (time_spec_removes[date]) { if (macro_f_file_type_is_directory(stats[type].st_mode)) { - will_return(__wrap_fl_directory_do, 0); - will_return(__wrap_fl_directory_do, F_okay); + will_return(__wrap_fl_directory_do, 1); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_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(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); } @@ -698,7 +734,7 @@ void test__kt_remove__date_accessed__yesterday_works(void **state) { const f_time_spec_t time_spec_clocks = macro_f_time_spec_t_initialize_1(2 * 86400, 345); - bool time_spec_removes[] = { + uint8_t time_spec_removes[] = { F_false, // Equal F_false, F_false, @@ -752,8 +788,17 @@ void test__kt_remove__date_accessed__yesterday_works(void **state) { if (time_spec_removes[date]) { if (macro_f_file_type_is_directory(stats[type].st_mode)) { - will_return(__wrap_fl_directory_do, 0); - will_return(__wrap_fl_directory_do, F_okay); + will_return(__wrap_fl_directory_do, 1); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_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(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); } diff --git a/tests/unit/remove/c/test-remove-date_changed.c b/tests/unit/remove/c/test-remove-date_changed.c index c3ebf0e..59efe80 100644 --- a/tests/unit/remove/c/test-remove-date_changed.c +++ b/tests/unit/remove/c/test-remove-date_changed.c @@ -91,7 +91,7 @@ void test__kt_remove__date_changed__date_works(void **state) { macro_f_time_spec_t_initialize_1(1672429502, 0), }; - bool time_spec_removes[] = { + uint8_t time_spec_removes[] = { F_false, // Equal F_false, F_false, @@ -139,8 +139,17 @@ void test__kt_remove__date_changed__date_works(void **state) { if (time_spec_removes[date]) { if (macro_f_file_type_is_directory(stats[type].st_mode)) { - will_return(__wrap_fl_directory_do, 0); - will_return(__wrap_fl_directory_do, F_okay); + will_return(__wrap_fl_directory_do, 1); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_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(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); } @@ -239,7 +248,7 @@ void test__kt_remove__date_changed__now_works(void **state) { const f_time_spec_t time_spec_clocks = macro_f_time_spec_t_initialize_1(2 * 86400, 123); - bool time_spec_removes[] = { + uint8_t time_spec_removes[] = { F_true, // Equal F_false, F_false, @@ -293,8 +302,17 @@ void test__kt_remove__date_changed__now_works(void **state) { if (time_spec_removes[date]) { if (macro_f_file_type_is_directory(stats[type].st_mode)) { - will_return(__wrap_fl_directory_do, 0); - will_return(__wrap_fl_directory_do, F_okay); + will_return(__wrap_fl_directory_do, 1); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_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(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); } @@ -392,7 +410,7 @@ void test__kt_remove__date_changed__today_works(void **state) { const f_time_spec_t time_spec_clocks = macro_f_time_spec_t_initialize_1(2 * 86400, 123); - bool time_spec_removes[] = { + uint8_t time_spec_removes[] = { F_true, // Equal F_true, F_false, @@ -446,8 +464,17 @@ void test__kt_remove__date_changed__today_works(void **state) { if (time_spec_removes[date]) { if (macro_f_file_type_is_directory(stats[type].st_mode)) { - will_return(__wrap_fl_directory_do, 0); - will_return(__wrap_fl_directory_do, F_okay); + will_return(__wrap_fl_directory_do, 1); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_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(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); } @@ -545,7 +572,7 @@ void test__kt_remove__date_changed__tomorrow_works(void **state) { const f_time_spec_t time_spec_clocks = macro_f_time_spec_t_initialize_1(2 * 86400, 123); - bool time_spec_removes[] = { + uint8_t time_spec_removes[] = { F_false, // Equal F_false, F_true, @@ -599,8 +626,17 @@ void test__kt_remove__date_changed__tomorrow_works(void **state) { if (time_spec_removes[date]) { if (macro_f_file_type_is_directory(stats[type].st_mode)) { - will_return(__wrap_fl_directory_do, 0); - will_return(__wrap_fl_directory_do, F_okay); + will_return(__wrap_fl_directory_do, 1); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_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(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); } @@ -698,7 +734,7 @@ void test__kt_remove__date_changed__yesterday_works(void **state) { const f_time_spec_t time_spec_clocks = macro_f_time_spec_t_initialize_1(2 * 86400, 345); - bool time_spec_removes[] = { + uint8_t time_spec_removes[] = { F_false, // Equal F_false, F_false, @@ -752,8 +788,17 @@ void test__kt_remove__date_changed__yesterday_works(void **state) { if (time_spec_removes[date]) { if (macro_f_file_type_is_directory(stats[type].st_mode)) { - will_return(__wrap_fl_directory_do, 0); - will_return(__wrap_fl_directory_do, F_okay); + will_return(__wrap_fl_directory_do, 1); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_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(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); } diff --git a/tests/unit/remove/c/test-remove-date_updated.c b/tests/unit/remove/c/test-remove-date_updated.c index e30749e..faa76c8 100644 --- a/tests/unit/remove/c/test-remove-date_updated.c +++ b/tests/unit/remove/c/test-remove-date_updated.c @@ -91,7 +91,7 @@ void test__kt_remove__date_updated__date_works(void **state) { macro_f_time_spec_t_initialize_1(1672429502, 0), }; - bool time_spec_removes[] = { + uint8_t time_spec_removes[] = { F_false, // Equal F_false, F_false, @@ -139,8 +139,17 @@ void test__kt_remove__date_updated__date_works(void **state) { if (time_spec_removes[date]) { if (macro_f_file_type_is_directory(stats[type].st_mode)) { - will_return(__wrap_fl_directory_do, 0); - will_return(__wrap_fl_directory_do, F_okay); + will_return(__wrap_fl_directory_do, 1); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_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(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); } @@ -239,7 +248,7 @@ void test__kt_remove__date_updated__now_works(void **state) { const f_time_spec_t time_spec_clocks = macro_f_time_spec_t_initialize_1(2 * 86400, 123); - bool time_spec_removes[] = { + uint8_t time_spec_removes[] = { F_true, // Equal F_false, F_false, @@ -293,8 +302,17 @@ void test__kt_remove__date_updated__now_works(void **state) { if (time_spec_removes[date]) { if (macro_f_file_type_is_directory(stats[type].st_mode)) { - will_return(__wrap_fl_directory_do, 0); - will_return(__wrap_fl_directory_do, F_okay); + will_return(__wrap_fl_directory_do, 1); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_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(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); } @@ -392,7 +410,7 @@ void test__kt_remove__date_updated__today_works(void **state) { const f_time_spec_t time_spec_clocks = macro_f_time_spec_t_initialize_1(2 * 86400, 123); - bool time_spec_removes[] = { + uint8_t time_spec_removes[] = { F_true, // Equal F_true, F_false, @@ -446,8 +464,17 @@ void test__kt_remove__date_updated__today_works(void **state) { if (time_spec_removes[date]) { if (macro_f_file_type_is_directory(stats[type].st_mode)) { - will_return(__wrap_fl_directory_do, 0); - will_return(__wrap_fl_directory_do, F_okay); + will_return(__wrap_fl_directory_do, 1); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_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(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); } @@ -545,7 +572,7 @@ void test__kt_remove__date_updated__tomorrow_works(void **state) { const f_time_spec_t time_spec_clocks = macro_f_time_spec_t_initialize_1(2 * 86400, 123); - bool time_spec_removes[] = { + uint8_t time_spec_removes[] = { F_false, // Equal F_false, F_true, @@ -599,8 +626,17 @@ void test__kt_remove__date_updated__tomorrow_works(void **state) { if (time_spec_removes[date]) { if (macro_f_file_type_is_directory(stats[type].st_mode)) { - will_return(__wrap_fl_directory_do, 0); - will_return(__wrap_fl_directory_do, F_okay); + will_return(__wrap_fl_directory_do, 1); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_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(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); } @@ -698,7 +734,7 @@ void test__kt_remove__date_updated__yesterday_works(void **state) { const f_time_spec_t time_spec_clocks = macro_f_time_spec_t_initialize_1(2 * 86400, 345); - bool time_spec_removes[] = { + uint8_t time_spec_removes[] = { F_false, // Equal F_false, F_false, @@ -752,8 +788,17 @@ void test__kt_remove__date_updated__yesterday_works(void **state) { if (time_spec_removes[date]) { if (macro_f_file_type_is_directory(stats[type].st_mode)) { - will_return(__wrap_fl_directory_do, 0); - will_return(__wrap_fl_directory_do, F_okay); + will_return(__wrap_fl_directory_do, 1); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_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(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); } diff --git a/tests/unit/remove/c/test-remove-directory_no_args.c b/tests/unit/remove/c/test-remove-directory_no_args.c index 8ff25c4..fe417c2 100644 --- a/tests/unit/remove/c/test-remove-directory_no_args.c +++ b/tests/unit/remove/c/test-remove-directory_no_args.c @@ -12,17 +12,17 @@ void test__kt_remove__directory_no_args__one_empty_exists_link(void **state) { mock_unwrap = 0; mock_unwrap_f_time_clock_get = 1; - const f_string_static_t file = macro_f_string_static_t_initialize_1("to_remove", 0, 9); + const f_string_static_t target = macro_f_string_static_t_initialize_1("to_remove", 0, 9); struct stat statistics; { - const f_string_t argv[] = { "mocked_main", file.string, 0 }; + 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_file_operate_remove_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_file_operate_link_d is set. will_return(__wrap_f_file_stat, &statistics); @@ -30,8 +30,17 @@ void test__kt_remove__directory_no_args__one_empty_exists_link(void **state) { // Directory processing. will_return(__wrap_f_directory_empty, F_true); - will_return(__wrap_fl_directory_do, 0); - will_return(__wrap_fl_directory_do, F_okay); + will_return(__wrap_fl_directory_do, 1); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_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); @@ -42,12 +51,12 @@ void test__kt_remove__directory_no_args__one_empty_exists_link(void **state) { } { - const f_string_t argv[] = { "mocked_main", file.string, "+" F_console_standard_short_verbose_s, 0 }; + 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_file_operate_remove_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_file_operate_link_d is set. will_return(__wrap_f_file_stat, &statistics); @@ -55,8 +64,17 @@ void test__kt_remove__directory_no_args__one_empty_exists_link(void **state) { // Directory processing. will_return(__wrap_f_directory_empty, F_true); - will_return(__wrap_fl_directory_do, 0); - will_return(__wrap_fl_directory_do, F_okay); + will_return(__wrap_fl_directory_do, 1); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_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); @@ -67,12 +85,12 @@ void test__kt_remove__directory_no_args__one_empty_exists_link(void **state) { } { - const f_string_t argv[] = { "mocked_main", file.string, "+" F_console_standard_short_debug_s, 0 }; + 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_file_operate_remove_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_file_operate_link_d is set. will_return(__wrap_f_file_stat, &statistics); @@ -80,8 +98,17 @@ void test__kt_remove__directory_no_args__one_empty_exists_link(void **state) { // Directory processing. will_return(__wrap_f_directory_empty, F_true); - will_return(__wrap_fl_directory_do, 0); - will_return(__wrap_fl_directory_do, F_okay); + will_return(__wrap_fl_directory_do, 1); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_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); @@ -97,17 +124,17 @@ void test__kt_remove__directory_no_args__one_empty_exists_link_not(void **state) mock_unwrap = 0; mock_unwrap_f_time_clock_get = 1; - const f_string_static_t file = macro_f_string_static_t_initialize_1("to_remove", 0, 9); + const f_string_static_t target = macro_f_string_static_t_initialize_1("to_remove", 0, 9); struct stat statistics; { - const f_string_t argv[] = { "mocked_main", file.string, 0 }; + 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_file_operate_remove_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_file_operate_link_d is not set. will_return(__wrap_f_file_stat, &statistics); @@ -115,8 +142,17 @@ void test__kt_remove__directory_no_args__one_empty_exists_link_not(void **state) // Directory processing. will_return(__wrap_f_directory_empty, F_true); - will_return(__wrap_fl_directory_do, 0); - will_return(__wrap_fl_directory_do, F_okay); + will_return(__wrap_fl_directory_do, 1); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_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); @@ -127,12 +163,12 @@ void test__kt_remove__directory_no_args__one_empty_exists_link_not(void **state) } { - const f_string_t argv[] = { "mocked_main", file.string, "+" F_console_standard_short_verbose_s, 0 }; + 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_file_operate_remove_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_file_operate_link_d is not set. will_return(__wrap_f_file_stat, &statistics); @@ -140,8 +176,17 @@ void test__kt_remove__directory_no_args__one_empty_exists_link_not(void **state) // Directory processing. will_return(__wrap_f_directory_empty, F_true); - will_return(__wrap_fl_directory_do, 0); - will_return(__wrap_fl_directory_do, F_okay); + will_return(__wrap_fl_directory_do, 1); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_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); @@ -152,12 +197,12 @@ void test__kt_remove__directory_no_args__one_empty_exists_link_not(void **state) } { - const f_string_t argv[] = { "mocked_main", file.string, "+" F_console_standard_short_debug_s, 0 }; + 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_file_operate_remove_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_file_operate_link_d is not set. will_return(__wrap_f_file_stat, &statistics); @@ -165,8 +210,17 @@ void test__kt_remove__directory_no_args__one_empty_exists_link_not(void **state) // Directory processing. will_return(__wrap_f_directory_empty, F_true); - will_return(__wrap_fl_directory_do, 0); - will_return(__wrap_fl_directory_do, F_okay); + will_return(__wrap_fl_directory_do, 1); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_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); @@ -182,10 +236,10 @@ void test__kt_remove__directory_no_args__one_empty_exists_not(void **state) { mock_unwrap = 0; mock_unwrap_f_time_clock_get = 1; - const f_string_static_t file = macro_f_string_static_t_initialize_1("to_remove", 0, 9); + const f_string_static_t target = macro_f_string_static_t_initialize_1("to_remove", 0, 9); { - const f_string_t argv[] = { "mocked_main", file.string, 0 }; + const f_string_t argv[] = { "mocked_main", target.string, 0 }; will_return(__wrap_f_file_exists, F_false); @@ -195,7 +249,7 @@ void test__kt_remove__directory_no_args__one_empty_exists_not(void **state) { } { - const f_string_t argv[] = { "mocked_main", file.string, "+" F_console_standard_short_verbose_s, 0 }; + const f_string_t argv[] = { "mocked_main", target.string, "+" F_console_standard_short_verbose_s, 0 }; will_return(__wrap_f_file_exists, F_false); @@ -205,7 +259,7 @@ void test__kt_remove__directory_no_args__one_empty_exists_not(void **state) { } { - const f_string_t argv[] = { "mocked_main", file.string, "+" F_console_standard_short_debug_s, 0 }; + const f_string_t argv[] = { "mocked_main", target.string, "+" F_console_standard_short_debug_s, 0 }; will_return(__wrap_f_file_exists, F_false); @@ -220,13 +274,13 @@ void test__kt_remove__directory_no_args__one_empty_not_exists_link(void **state) mock_unwrap = 0; mock_unwrap_f_time_clock_get = 1; - const f_string_static_t file = macro_f_string_static_t_initialize_1("to_remove", 0, 9); + const f_string_static_t target = macro_f_string_static_t_initialize_1("to_remove", 0, 9); struct stat statistics; struct stat statistics_regular; { - const f_string_t argv[] = { "mocked_main", file.string, "-" KT_REMOVE_short_empty_s, KT_REMOVE_not_s, 0 }; + 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_file_operate_remove_d. @@ -234,7 +288,7 @@ void test__kt_remove__directory_no_args__one_empty_not_exists_link(void **state) 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_file_operate_remove_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_file_operate_link_d is set. will_return(__wrap_f_file_stat, &statistics); @@ -243,8 +297,8 @@ void test__kt_remove__directory_no_args__one_empty_not_exists_link(void **state) // Directory processing. will_return(__wrap_f_directory_empty, F_false); // kt_remove_flag_file_operate_empty_d is set. will_return(__wrap_fl_directory_do, 1); - will_return(__wrap_fl_directory_do, &file); - will_return(__wrap_fl_directory_do, &file); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, &target); 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. @@ -252,8 +306,9 @@ void test__kt_remove__directory_no_args__one_empty_not_exists_link(void **state) will_return(__wrap_f_file_is, F_true); // A link, kt_remove_flag_file_operate_link_d is set. will_return(__wrap_f_file_stat, &statistics); will_return(__wrap_f_file_stat, F_okay); - will_return(__wrap_f_directory_empty, F_true); + will_return(__wrap_f_directory_empty, F_false); + // @fixme when removal is attempted on non-empty directory due to empty not flag being set this likely should fail to remove on error that directory is not empty (recursive would need to be passed to succeed). // 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); @@ -263,7 +318,7 @@ void test__kt_remove__directory_no_args__one_empty_not_exists_link(void **state) } { - const f_string_t argv[] = { "mocked_main", file.string, "+" F_console_standard_short_verbose_s, "-" KT_REMOVE_short_empty_s, KT_REMOVE_not_s, 0 }; + 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_file_operate_remove_d. @@ -271,7 +326,7 @@ void test__kt_remove__directory_no_args__one_empty_not_exists_link(void **state) 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_file_operate_remove_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_file_operate_link_d is set. will_return(__wrap_f_file_stat, &statistics); @@ -280,8 +335,8 @@ void test__kt_remove__directory_no_args__one_empty_not_exists_link(void **state) // Directory processing. will_return(__wrap_f_directory_empty, F_false); // kt_remove_flag_file_operate_empty_d is set. will_return(__wrap_fl_directory_do, 1); - will_return(__wrap_fl_directory_do, &file); - will_return(__wrap_fl_directory_do, &file); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, &target); 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. @@ -289,7 +344,7 @@ void test__kt_remove__directory_no_args__one_empty_not_exists_link(void **state) will_return(__wrap_f_file_is, F_true); // A link, kt_remove_flag_file_operate_link_d is set. will_return(__wrap_f_file_stat, &statistics); will_return(__wrap_f_file_stat, F_okay); - will_return(__wrap_f_directory_empty, F_true); + 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); @@ -300,7 +355,7 @@ void test__kt_remove__directory_no_args__one_empty_not_exists_link(void **state) } { - const f_string_t argv[] = { "mocked_main", file.string, "+" F_console_standard_short_debug_s, "-" KT_REMOVE_short_empty_s, KT_REMOVE_not_s, 0 }; + 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_file_operate_remove_d. @@ -308,7 +363,7 @@ void test__kt_remove__directory_no_args__one_empty_not_exists_link(void **state) 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_file_operate_remove_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_file_operate_link_d is set. will_return(__wrap_f_file_stat, &statistics); @@ -317,8 +372,8 @@ void test__kt_remove__directory_no_args__one_empty_not_exists_link(void **state) // Directory processing. will_return(__wrap_f_directory_empty, F_false); // kt_remove_flag_file_operate_empty_d is set. will_return(__wrap_fl_directory_do, 1); - will_return(__wrap_fl_directory_do, &file); - will_return(__wrap_fl_directory_do, &file); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, &target); 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. @@ -326,7 +381,7 @@ void test__kt_remove__directory_no_args__one_empty_not_exists_link(void **state) will_return(__wrap_f_file_is, F_true); // A link, kt_remove_flag_file_operate_link_d is set. will_return(__wrap_f_file_stat, &statistics); will_return(__wrap_f_file_stat, F_okay); - will_return(__wrap_f_directory_empty, F_true); + 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); @@ -342,14 +397,14 @@ void test__kt_remove__directory_no_args__one_empty_not_exists_link_not(void **st mock_unwrap = 0; mock_unwrap_f_time_clock_get = 1; - const f_string_static_t file = macro_f_string_static_t_initialize_1("to_remove", 0, 9); + const f_string_static_t 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; { - const f_string_t argv[] = { "mocked_main", file.string, "-" KT_REMOVE_short_empty_s, KT_REMOVE_not_s, 0 }; + 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_file_operate_remove_d. @@ -357,7 +412,7 @@ void test__kt_remove__directory_no_args__one_empty_not_exists_link_not(void **st 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_file_operate_remove_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_file_operate_link_d is not set. will_return(__wrap_f_file_stat, &statistics); @@ -365,18 +420,29 @@ void test__kt_remove__directory_no_args__one_empty_not_exists_link_not(void **st // Directory processing. will_return(__wrap_f_directory_empty, F_false); // kt_remove_flag_file_operate_empty_d is set. - will_return(__wrap_fl_directory_do, 1); - - // Child + will_return(__wrap_fl_directory_do, 2); 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_f_file_exists, F_true); will_return(__wrap_f_file_is, F_false); // Not a link, kt_remove_flag_file_operate_link_d is not set. will_return(__wrap_f_file_stat, &statistics_regular); will_return(__wrap_f_file_stat, F_okay); will_return(__wrap_f_file_remove, F_okay); + // Parent directory. + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_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_file_operate_link_d is set. + will_return(__wrap_f_file_stat, &statistics); + will_return(__wrap_f_file_stat, F_okay); + will_return(__wrap_f_directory_empty, F_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); @@ -386,7 +452,7 @@ void test__kt_remove__directory_no_args__one_empty_not_exists_link_not(void **st } { - const f_string_t argv[] = { "mocked_main", file.string, "+" F_console_standard_short_verbose_s, "-" KT_REMOVE_short_empty_s, KT_REMOVE_not_s, 0 }; + 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_file_operate_remove_d. @@ -394,7 +460,7 @@ void test__kt_remove__directory_no_args__one_empty_not_exists_link_not(void **st 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_file_operate_remove_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_file_operate_link_d is not set. will_return(__wrap_f_file_stat, &statistics); @@ -402,17 +468,28 @@ void test__kt_remove__directory_no_args__one_empty_not_exists_link_not(void **st // Directory processing. will_return(__wrap_f_directory_empty, F_false); // kt_remove_flag_file_operate_empty_d is set. - will_return(__wrap_fl_directory_do, 1); - will_return(__wrap_fl_directory_do, &file); - will_return(__wrap_fl_directory_do, &file); + will_return(__wrap_fl_directory_do, 2); + 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_f_file_exists, F_true); + will_return(__wrap_f_file_is, F_false); // Not a link, kt_remove_flag_file_operate_link_d is not set. + will_return(__wrap_f_file_stat, &statistics_regular); + will_return(__wrap_f_file_stat, F_okay); + will_return(__wrap_f_file_remove, F_okay); + + // Parent directory. + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, &target); will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_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); // Not a link, kt_remove_flag_file_operate_link_d is not set. + will_return(__wrap_f_file_is, F_true); // A link, kt_remove_flag_file_operate_link_d is set. will_return(__wrap_f_file_stat, &statistics); will_return(__wrap_f_file_stat, F_okay); - will_return(__wrap_f_directory_empty, F_true); + 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); @@ -423,7 +500,7 @@ void test__kt_remove__directory_no_args__one_empty_not_exists_link_not(void **st } { - const f_string_t argv[] = { "mocked_main", file.string, "+" F_console_standard_short_debug_s, "-" KT_REMOVE_short_empty_s, KT_REMOVE_not_s, 0 }; + 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_file_operate_remove_d. @@ -431,7 +508,7 @@ void test__kt_remove__directory_no_args__one_empty_not_exists_link_not(void **st 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_file_operate_remove_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_file_operate_link_d is not set. will_return(__wrap_f_file_stat, &statistics); @@ -439,17 +516,28 @@ void test__kt_remove__directory_no_args__one_empty_not_exists_link_not(void **st // Directory processing. will_return(__wrap_f_directory_empty, F_false); // kt_remove_flag_file_operate_empty_d is set. - will_return(__wrap_fl_directory_do, 1); - will_return(__wrap_fl_directory_do, &file); - will_return(__wrap_fl_directory_do, &file); + will_return(__wrap_fl_directory_do, 2); + 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_f_file_exists, F_true); + will_return(__wrap_f_file_is, F_false); // Not a link, kt_remove_flag_file_operate_link_d is not set. + will_return(__wrap_f_file_stat, &statistics_regular); + will_return(__wrap_f_file_stat, F_okay); + will_return(__wrap_f_file_remove, F_okay); + + // Parent directory. + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, &target); will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_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); // Not a link, kt_remove_flag_file_operate_link_d is not set. + will_return(__wrap_f_file_is, F_true); // A link, kt_remove_flag_file_operate_link_d is set. will_return(__wrap_f_file_stat, &statistics); will_return(__wrap_f_file_stat, F_okay); - will_return(__wrap_f_directory_empty, F_true); + 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); @@ -465,18 +553,18 @@ void test__kt_remove__directory_no_args__two_empty_exists_and_not(void **state) mock_unwrap = 0; mock_unwrap_f_time_clock_get = 1; - const f_string_static_t file = macro_f_string_static_t_initialize_1("to_remove", 0, 9); - const f_string_static_t file_also = macro_f_string_static_t_initialize_1("also/remove", 0, 11); + 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; { - const f_string_t argv[] = { "mocked_main", file.string, file_also.string, 0 }; + 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_file_operate_remove_d. - // Pre-process file 1. + // Pre-process target 1. will_return(__wrap_f_file_exists, F_false); const int result = kt_main_test__remove(3, argv, 0); @@ -485,12 +573,12 @@ void test__kt_remove__directory_no_args__two_empty_exists_and_not(void **state) } { - const f_string_t argv[] = { "mocked_main", file.string, file_also.string, "+" F_console_standard_short_verbose_s, 0 }; + 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_file_operate_remove_d. - // Pre-process file 1. + // Pre-process target 1. will_return(__wrap_f_file_exists, F_false); const int result = kt_main_test__remove(4, argv, 0); @@ -499,12 +587,12 @@ void test__kt_remove__directory_no_args__two_empty_exists_and_not(void **state) } { - const f_string_t argv[] = { "mocked_main", file.string, file_also.string, "+" F_console_standard_short_debug_s, 0 }; + 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_file_operate_remove_d. - // Pre-process file 1. + // Pre-process target 1. will_return(__wrap_f_file_exists, F_false); const int result = kt_main_test__remove(4, argv, 0); @@ -518,18 +606,18 @@ void test__kt_remove__directory_no_args__two_empty_exists_link(void **state) { mock_unwrap = 0; mock_unwrap_f_time_clock_get = 1; - const f_string_static_t file = macro_f_string_static_t_initialize_1("to_remove", 0, 9); - const f_string_static_t file_also = macro_f_string_static_t_initialize_1("also/remove", 0, 11); + 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; { - const f_string_t argv[] = { "mocked_main", file.string, file_also.string, 0 }; + 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_file_operate_remove_d. - // Pre-process file 1. + // 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_file_operate_link_d is set. will_return(__wrap_f_file_stat, &statistics); @@ -537,13 +625,22 @@ void test__kt_remove__directory_no_args__two_empty_exists_link(void **state) { // Directory processing. will_return(__wrap_f_directory_empty, F_true); - will_return(__wrap_fl_directory_do, 0); - will_return(__wrap_fl_directory_do, F_okay); + will_return(__wrap_fl_directory_do, 1); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_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 file 2. + // 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_file_operate_link_d is set. will_return(__wrap_f_file_stat, &statistics); @@ -551,8 +648,17 @@ void test__kt_remove__directory_no_args__two_empty_exists_link(void **state) { // Directory processing. will_return(__wrap_f_directory_empty, F_true); - will_return(__wrap_fl_directory_do, 0); - will_return(__wrap_fl_directory_do, F_okay); + will_return(__wrap_fl_directory_do, 1); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_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); @@ -563,12 +669,12 @@ void test__kt_remove__directory_no_args__two_empty_exists_link(void **state) { } { - const f_string_t argv[] = { "mocked_main", file.string, file_also.string, "+" F_console_standard_short_verbose_s, 0 }; + 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_file_operate_remove_d. - // Pre-process file 1. + // 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_file_operate_link_d is set. will_return(__wrap_f_file_stat, &statistics); @@ -576,13 +682,22 @@ void test__kt_remove__directory_no_args__two_empty_exists_link(void **state) { // Directory processing. will_return(__wrap_f_directory_empty, F_true); - will_return(__wrap_fl_directory_do, 0); - will_return(__wrap_fl_directory_do, F_okay); + will_return(__wrap_fl_directory_do, 1); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_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 file 2. + // 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_file_operate_link_d is set. will_return(__wrap_f_file_stat, &statistics); @@ -590,8 +705,17 @@ void test__kt_remove__directory_no_args__two_empty_exists_link(void **state) { // Directory processing. will_return(__wrap_f_directory_empty, F_true); - will_return(__wrap_fl_directory_do, 0); - will_return(__wrap_fl_directory_do, F_okay); + will_return(__wrap_fl_directory_do, 1); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_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); @@ -602,12 +726,12 @@ void test__kt_remove__directory_no_args__two_empty_exists_link(void **state) { } { - const f_string_t argv[] = { "mocked_main", file.string, file_also.string, "+" F_console_standard_short_debug_s, 0 }; + 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_file_operate_remove_d. - // Pre-process file 1. + // 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_file_operate_link_d is set. will_return(__wrap_f_file_stat, &statistics); @@ -615,13 +739,22 @@ void test__kt_remove__directory_no_args__two_empty_exists_link(void **state) { // Directory processing. will_return(__wrap_f_directory_empty, F_true); - will_return(__wrap_fl_directory_do, 0); - will_return(__wrap_fl_directory_do, F_okay); + will_return(__wrap_fl_directory_do, 1); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_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 file 2. + // 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_file_operate_link_d is set. will_return(__wrap_f_file_stat, &statistics); @@ -629,8 +762,17 @@ void test__kt_remove__directory_no_args__two_empty_exists_link(void **state) { // Directory processing. will_return(__wrap_f_directory_empty, F_true); - will_return(__wrap_fl_directory_do, 0); - will_return(__wrap_fl_directory_do, F_okay); + will_return(__wrap_fl_directory_do, 1); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_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); @@ -646,18 +788,18 @@ void test__kt_remove__directory_no_args__two_empty_exists_link_not(void **state) mock_unwrap = 0; mock_unwrap_f_time_clock_get = 1; - const f_string_static_t file = macro_f_string_static_t_initialize_1("to_remove", 0, 9); - const f_string_static_t file_also = macro_f_string_static_t_initialize_1("also/remove", 0, 11); + 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; { - const f_string_t argv[] = { "mocked_main", file.string, file_also.string, 0 }; + 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_file_operate_remove_d. - // Pre-process file 1. + // 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_file_operate_link_d is not set. will_return(__wrap_f_file_stat, &statistics); @@ -665,13 +807,22 @@ void test__kt_remove__directory_no_args__two_empty_exists_link_not(void **state) // Directory processing. will_return(__wrap_f_directory_empty, F_true); - will_return(__wrap_fl_directory_do, 0); - will_return(__wrap_fl_directory_do, F_okay); + will_return(__wrap_fl_directory_do, 1); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_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 file 2. + // 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_file_operate_link_d is set. will_return(__wrap_f_file_stat, &statistics); @@ -679,8 +830,17 @@ void test__kt_remove__directory_no_args__two_empty_exists_link_not(void **state) // Directory processing. will_return(__wrap_f_directory_empty, F_true); - will_return(__wrap_fl_directory_do, 0); - will_return(__wrap_fl_directory_do, F_okay); + will_return(__wrap_fl_directory_do, 1); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_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); @@ -691,12 +851,12 @@ void test__kt_remove__directory_no_args__two_empty_exists_link_not(void **state) } { - const f_string_t argv[] = { "mocked_main", file.string, file_also.string, "+" F_console_standard_short_verbose_s, 0 }; + 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_file_operate_remove_d. - // Pre-process file 1. + // 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_file_operate_link_d is not set. will_return(__wrap_f_file_stat, &statistics); @@ -704,13 +864,22 @@ void test__kt_remove__directory_no_args__two_empty_exists_link_not(void **state) // Directory processing. will_return(__wrap_f_directory_empty, F_true); - will_return(__wrap_fl_directory_do, 0); - will_return(__wrap_fl_directory_do, F_okay); + will_return(__wrap_fl_directory_do, 1); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_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 file 2. + // 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_file_operate_link_d is set. will_return(__wrap_f_file_stat, &statistics); @@ -718,8 +887,17 @@ void test__kt_remove__directory_no_args__two_empty_exists_link_not(void **state) // Directory processing. will_return(__wrap_f_directory_empty, F_true); - will_return(__wrap_fl_directory_do, 0); - will_return(__wrap_fl_directory_do, F_okay); + will_return(__wrap_fl_directory_do, 1); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_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); @@ -730,12 +908,12 @@ void test__kt_remove__directory_no_args__two_empty_exists_link_not(void **state) } { - const f_string_t argv[] = { "mocked_main", file.string, file_also.string, "+" F_console_standard_short_debug_s, 0 }; + 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_file_operate_remove_d. - // Pre-process file 1. + // 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_file_operate_link_d is not set. will_return(__wrap_f_file_stat, &statistics); @@ -743,13 +921,22 @@ void test__kt_remove__directory_no_args__two_empty_exists_link_not(void **state) // Directory processing. will_return(__wrap_f_directory_empty, F_true); - will_return(__wrap_fl_directory_do, 0); - will_return(__wrap_fl_directory_do, F_okay); + will_return(__wrap_fl_directory_do, 1); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_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 file 2. + // 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_file_operate_link_d is set. will_return(__wrap_f_file_stat, &statistics); @@ -757,8 +944,17 @@ void test__kt_remove__directory_no_args__two_empty_exists_link_not(void **state) // Directory processing. will_return(__wrap_f_directory_empty, F_true); - will_return(__wrap_fl_directory_do, 0); - will_return(__wrap_fl_directory_do, F_okay); + will_return(__wrap_fl_directory_do, 1); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_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); @@ -774,11 +970,11 @@ void test__kt_remove__directory_no_args__two_empty_exists_not(void **state) { mock_unwrap = 0; mock_unwrap_f_time_clock_get = 1; - const f_string_static_t file = macro_f_string_static_t_initialize_1("to_remove", 0, 9); - const f_string_static_t file_also = macro_f_string_static_t_initialize_1("also/remove", 0, 11); + 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); { - const f_string_t argv[] = { "mocked_main", file.string, file_also.string, 0 }; + const f_string_t argv[] = { "mocked_main", target.string, target_also.string, 0 }; will_return(__wrap_f_file_exists, F_false); @@ -788,7 +984,7 @@ void test__kt_remove__directory_no_args__two_empty_exists_not(void **state) { } { - const f_string_t argv[] = { "mocked_main", file.string, file_also.string, "+" F_console_standard_short_verbose_s, 0 }; + 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); @@ -798,7 +994,7 @@ void test__kt_remove__directory_no_args__two_empty_exists_not(void **state) { } { - const f_string_t argv[] = { "mocked_main", file.string, file_also.string, "+" F_console_standard_short_debug_s, 0 }; + 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); diff --git a/tests/unit/remove/c/test-remove-directory_recurse_simple.c b/tests/unit/remove/c/test-remove-directory_recurse_simple.c index f1b4c93..0c04b1a 100644 --- a/tests/unit/remove/c/test-remove-directory_recurse_simple.c +++ b/tests/unit/remove/c/test-remove-directory_recurse_simple.c @@ -35,7 +35,7 @@ void test__kt_remove__directory_recurse_simple__one_child_one_exists_link(void * // Target Directory pre-processing, begin, perform directory listing action. will_return(__wrap_f_directory_empty, F_false); - will_return(__wrap_fl_directory_do, 1); + will_return(__wrap_fl_directory_do, 2); // The first child pre-processing. will_return(__wrap_fl_directory_do, &child_1); @@ -47,6 +47,18 @@ void test__kt_remove__directory_recurse_simple__one_child_one_exists_link(void * will_return(__wrap_f_file_stat, F_okay); will_return(__wrap_f_file_remove, F_okay); + // The parent. + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_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); + will_return(__wrap_f_directory_remove, F_okay); const int result = kt_main_test__remove(3, argv, 0); @@ -83,7 +95,7 @@ void test__kt_remove__directory_recurse_simple__one_child_one_exists_link_not(vo // Target Directory pre-processing, begin, perform directory listing action. will_return(__wrap_f_directory_empty, F_false); - will_return(__wrap_fl_directory_do, 1); + will_return(__wrap_fl_directory_do, 2); // The first child pre-processing. will_return(__wrap_fl_directory_do, &child_1); @@ -95,6 +107,18 @@ void test__kt_remove__directory_recurse_simple__one_child_one_exists_link_not(vo will_return(__wrap_f_file_stat, F_okay); will_return(__wrap_f_file_remove, F_okay); + // The parent. + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_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); + will_return(__wrap_f_directory_remove, F_okay); const int result = kt_main_test__remove(3, argv, 0); @@ -132,7 +156,7 @@ void test__kt_remove__directory_recurse_simple__one_child_two_exists_link(void * // 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, 3); // The first child processing. will_return(__wrap_fl_directory_do, &child_1); @@ -154,6 +178,18 @@ void test__kt_remove__directory_recurse_simple__one_child_two_exists_link(void * will_return(__wrap_f_file_stat, F_okay); will_return(__wrap_f_file_remove, F_okay); + // The parent. + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_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); + will_return(__wrap_f_directory_remove, F_okay); const int result = kt_main_test__remove(3, argv, 0); @@ -191,7 +227,7 @@ void test__kt_remove__directory_recurse_simple__one_child_two_exists_link_not(vo // 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, 3); // The first child processing. will_return(__wrap_fl_directory_do, &child_1); @@ -213,6 +249,18 @@ void test__kt_remove__directory_recurse_simple__one_child_two_exists_link_not(vo will_return(__wrap_f_file_stat, F_okay); will_return(__wrap_f_file_remove, F_okay); + // The parent. + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_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); + will_return(__wrap_f_directory_remove, F_okay); const int result = kt_main_test__remove(3, argv, 0); diff --git a/tests/unit/remove/c/test-remove-epochtime.c b/tests/unit/remove/c/test-remove-epochtime.c index bfacdf6..6721fa4 100644 --- a/tests/unit/remove/c/test-remove-epochtime.c +++ b/tests/unit/remove/c/test-remove-epochtime.c @@ -90,7 +90,7 @@ void test__kt_remove__epochtime__accessed_works(void **state) { macro_f_time_spec_t_initialize_1(1 * 86400, 4000), }; - bool time_spec_removes[] = { + uint8_t time_spec_removes[] = { F_true, // Equal F_true, F_false, @@ -144,8 +144,17 @@ void test__kt_remove__epochtime__accessed_works(void **state) { if (time_spec_removes[date]) { if (macro_f_file_type_is_directory(stats[type].st_mode)) { - will_return(__wrap_fl_directory_do, 0); - will_return(__wrap_fl_directory_do, F_okay); + will_return(__wrap_fl_directory_do, 1); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_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(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); } @@ -246,7 +255,7 @@ void test__kt_remove__epochtime__changed_works(void **state) { macro_f_time_spec_t_initialize_1(1 * 86400, 4000), }; - bool time_spec_removes[] = { + uint8_t time_spec_removes[] = { F_true, // Equal F_true, F_false, @@ -300,8 +309,17 @@ void test__kt_remove__epochtime__changed_works(void **state) { if (time_spec_removes[date]) { if (macro_f_file_type_is_directory(stats[type].st_mode)) { - will_return(__wrap_fl_directory_do, 0); - will_return(__wrap_fl_directory_do, F_okay); + will_return(__wrap_fl_directory_do, 1); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_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(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); } @@ -402,7 +420,7 @@ void test__kt_remove__epochtime__updated_works(void **state) { macro_f_time_spec_t_initialize_1(1 * 86400, 4000), }; - bool time_spec_removes[] = { + uint8_t time_spec_removes[] = { F_true, // Equal F_true, F_false, @@ -456,8 +474,17 @@ void test__kt_remove__epochtime__updated_works(void **state) { if (time_spec_removes[date]) { if (macro_f_file_type_is_directory(stats[type].st_mode)) { - will_return(__wrap_fl_directory_do, 0); - will_return(__wrap_fl_directory_do, F_okay); + will_return(__wrap_fl_directory_do, 1); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_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(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); } diff --git a/tests/unit/remove/c/test-remove-file_mode.c b/tests/unit/remove/c/test-remove-file_mode.c index c54dac2..13a6451 100644 --- a/tests/unit/remove/c/test-remove-file_mode.c +++ b/tests/unit/remove/c/test-remove-file_mode.c @@ -88,8 +88,17 @@ void test__kt_remove__file_mode__different_works(void **state) { if (param != mode) { if (macro_f_file_type_is_directory(statistics.st_mode)) { will_return(__wrap_f_directory_empty, F_true); - will_return(__wrap_fl_directory_do, 0); - will_return(__wrap_fl_directory_do, F_okay); + will_return(__wrap_fl_directory_do, 1); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_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); will_return(__wrap_f_directory_remove, F_okay); } @@ -193,8 +202,17 @@ void test__kt_remove__file_mode__same_works(void **state) { if (param == mode) { if (macro_f_file_type_is_directory(statistics.st_mode)) { will_return(__wrap_f_directory_empty, F_true); - will_return(__wrap_fl_directory_do, 0); - will_return(__wrap_fl_directory_do, F_okay); + will_return(__wrap_fl_directory_do, 1); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_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); will_return(__wrap_f_directory_remove, F_okay); } @@ -298,8 +316,17 @@ void test__kt_remove__file_mode__similar_works(void **state) { if (modes[param] & modes[mode]) { if (macro_f_file_type_is_directory(statistics.st_mode)) { will_return(__wrap_f_directory_empty, F_true); - will_return(__wrap_fl_directory_do, 0); - will_return(__wrap_fl_directory_do, F_okay); + will_return(__wrap_fl_directory_do, 1); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_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); will_return(__wrap_f_directory_remove, F_okay); } @@ -403,8 +430,17 @@ void test__kt_remove__file_mode__not_works(void **state) { if (modes[param] != modes[mode]) { if (macro_f_file_type_is_directory(statistics.st_mode)) { will_return(__wrap_f_directory_empty, F_true); - will_return(__wrap_fl_directory_do, 0); - will_return(__wrap_fl_directory_do, F_okay); + will_return(__wrap_fl_directory_do, 1); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_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); will_return(__wrap_f_directory_remove, F_okay); } diff --git a/tests/unit/remove/c/test-remove-file_type.c b/tests/unit/remove/c/test-remove-file_type.c index 622da78..9539b9f 100644 --- a/tests/unit/remove/c/test-remove-file_type.c +++ b/tests/unit/remove/c/test-remove-file_type.c @@ -60,8 +60,17 @@ void test__kt_remove__file_type__works(void **state) { if (i == type) { if (macro_f_file_type_is_directory(stats[i].st_mode)) { will_return(__wrap_f_directory_empty, F_true); - will_return(__wrap_fl_directory_do, 0); - will_return(__wrap_fl_directory_do, F_okay); + will_return(__wrap_fl_directory_do, 1); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_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(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); } diff --git a/tests/unit/remove/c/test-remove-group.c b/tests/unit/remove/c/test-remove-group.c index 6ee6e6e..90c6c8d 100644 --- a/tests/unit/remove/c/test-remove-group.c +++ b/tests/unit/remove/c/test-remove-group.c @@ -47,8 +47,17 @@ void test__kt_remove__group__name_works(void **state) { if (stats[type].st_gid == group_id) { if (macro_f_file_type_is_directory(stats[type].st_mode)) { will_return(__wrap_f_directory_empty, F_true); - will_return(__wrap_fl_directory_do, 0); - will_return(__wrap_fl_directory_do, F_okay); + will_return(__wrap_fl_directory_do, 1); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_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(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); } diff --git a/tests/unit/remove/c/test-remove-time.c b/tests/unit/remove/c/test-remove-time.c index b4d645f..bc51ed6 100644 --- a/tests/unit/remove/c/test-remove-time.c +++ b/tests/unit/remove/c/test-remove-time.c @@ -90,7 +90,7 @@ void test__kt_remove__time__accessed_works(void **state) { macro_f_time_spec_t_initialize_1(1 * 86400, 4000), }; - bool time_spec_removes[] = { + uint8_t time_spec_removes[] = { F_true, // Equal F_true, F_false, @@ -151,8 +151,17 @@ void test__kt_remove__time__accessed_works(void **state) { if (time_spec_removes[date]) { if (macro_f_file_type_is_directory(stats[type].st_mode)) { - will_return(__wrap_fl_directory_do, 0); - will_return(__wrap_fl_directory_do, F_okay); + will_return(__wrap_fl_directory_do, 1); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_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(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); } @@ -253,7 +262,7 @@ void test__kt_remove__time__changed_works(void **state) { macro_f_time_spec_t_initialize_1(1 * 86400, 4000), }; - bool time_spec_removes[] = { + uint8_t time_spec_removes[] = { F_true, // Equal F_true, F_false, @@ -314,8 +323,17 @@ void test__kt_remove__time__changed_works(void **state) { if (time_spec_removes[date]) { if (macro_f_file_type_is_directory(stats[type].st_mode)) { - will_return(__wrap_fl_directory_do, 0); - will_return(__wrap_fl_directory_do, F_okay); + will_return(__wrap_fl_directory_do, 1); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_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(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); } @@ -416,7 +434,7 @@ void test__kt_remove__time__updated_works(void **state) { macro_f_time_spec_t_initialize_1(1 * 86400, 4000), }; - bool time_spec_removes[] = { + uint8_t time_spec_removes[] = { F_true, // Equal F_true, F_false, @@ -477,8 +495,17 @@ void test__kt_remove__time__updated_works(void **state) { if (time_spec_removes[date]) { if (macro_f_file_type_is_directory(stats[type].st_mode)) { - will_return(__wrap_fl_directory_do, 0); - will_return(__wrap_fl_directory_do, F_okay); + will_return(__wrap_fl_directory_do, 1); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_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(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); } diff --git a/tests/unit/remove/c/test-remove-unix.c b/tests/unit/remove/c/test-remove-unix.c index 2a8a4c7..0845b72 100644 --- a/tests/unit/remove/c/test-remove-unix.c +++ b/tests/unit/remove/c/test-remove-unix.c @@ -87,7 +87,7 @@ void test__kt_remove__unix__accessed_works(void **state) { macro_f_time_spec_t_initialize_1(1 * 86400, 4000), }; - bool time_spec_removes[] = { + uint8_t time_spec_removes[] = { F_true, // Equal F_true, F_false, @@ -138,8 +138,17 @@ void test__kt_remove__unix__accessed_works(void **state) { if (time_spec_removes[date]) { if (macro_f_file_type_is_directory(stats[type].st_mode)) { - will_return(__wrap_fl_directory_do, 0); - will_return(__wrap_fl_directory_do, F_okay); + will_return(__wrap_fl_directory_do, 1); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_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(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); } @@ -235,7 +244,7 @@ void test__kt_remove__unix__changed_works(void **state) { macro_f_time_spec_t_initialize_1(1 * 86400, 4000), }; - bool time_spec_removes[] = { + uint8_t time_spec_removes[] = { F_true, // Equal F_true, F_false, @@ -286,8 +295,17 @@ void test__kt_remove__unix__changed_works(void **state) { if (time_spec_removes[date]) { if (macro_f_file_type_is_directory(stats[type].st_mode)) { - will_return(__wrap_fl_directory_do, 0); - will_return(__wrap_fl_directory_do, F_okay); + will_return(__wrap_fl_directory_do, 1); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_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(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); } @@ -383,7 +401,7 @@ void test__kt_remove__unix__updated_works(void **state) { macro_f_time_spec_t_initialize_1(1 * 86400, 4000), }; - bool time_spec_removes[] = { + uint8_t time_spec_removes[] = { F_true, // Equal F_true, F_false, @@ -434,8 +452,17 @@ void test__kt_remove__unix__updated_works(void **state) { if (time_spec_removes[date]) { if (macro_f_file_type_is_directory(stats[type].st_mode)) { - will_return(__wrap_fl_directory_do, 0); - will_return(__wrap_fl_directory_do, F_okay); + will_return(__wrap_fl_directory_do, 1); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_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(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); } diff --git a/tests/unit/remove/c/test-remove-user.c b/tests/unit/remove/c/test-remove-user.c index decf568..a3a4503 100644 --- a/tests/unit/remove/c/test-remove-user.c +++ b/tests/unit/remove/c/test-remove-user.c @@ -52,8 +52,19 @@ void test__kt_remove__user__different_works(void **state) { else { 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, 0); - will_return(__wrap_fl_directory_do, F_okay); + will_return(__wrap_fl_directory_do, 1); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_d | f_directory_recurse_do_flag_directory_d); + + // 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); } @@ -108,8 +119,17 @@ void test__kt_remove__user__name_works(void **state) { if (stats[type].st_uid == user_id) { if (macro_f_file_type_is_directory(stats[type].st_mode)) { will_return(__wrap_f_directory_empty, F_true); - will_return(__wrap_fl_directory_do, 0); - will_return(__wrap_fl_directory_do, F_okay); + will_return(__wrap_fl_directory_do, 1); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_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, &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); } @@ -169,8 +189,19 @@ void test__kt_remove__user__same_works(void **state) { if (stats[type].st_uid == user_id) { if (macro_f_file_type_is_directory(stats[type].st_mode)) { will_return(__wrap_f_directory_empty, F_true); - will_return(__wrap_fl_directory_do, 0); - will_return(__wrap_fl_directory_do, F_okay); + will_return(__wrap_fl_directory_do, 1); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, &target); + will_return(__wrap_fl_directory_do, f_directory_recurse_do_flag_action_d | f_directory_recurse_do_flag_directory_d); + + // 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); }