The fake_print_message_file() function is no longer needed and should be replaced with fll_error_file_print().
}
if (operation == fake_make_operation_type_clone) {
- const f_array_length_t total = arguments.used -1;
+ const f_array_length_t total = arguments.used - 1;
f_status_t status_file = F_none;
fl_directory_recurse_t recurse = fl_directory_recurse_t_initialize;
// in this case, the destination could be a file, so confirm this.
if (arguments.used == 2) {
- status_file = f_directory_is(arguments.array[total].string);
+ status_file = f_directory_is(arguments.array[1].string);
if (F_status_is_error(status_file)) {
- fake_print_message_file(data, data_make->error, F_status_set_fine(status_file), "f_directory_is", arguments.array[1].string, "identify", F_false, F_true);
+ fll_error_file_print(data_make->error, F_status_set_fine(status_file), "f_directory_is", F_true, arguments.array[1].string, "identify", fll_error_file_type_directory);
*status = F_status_set_error(F_failure);
return;
}
}
for (f_array_length_t i = 0; i < total; i++) {
+
destination_length = arguments.array[total].used;
if (existing) {
status_file = fl_directory_clone(arguments.array[i].string, destination, arguments.array[i].used, destination_length, F_true, recurse);
if (F_status_is_error(status_file)) {
- fake_print_message_file(data, data_make->error, F_status_set_fine(status_file), "fl_directory_clone", arguments.array[i].string, "clone", F_false, F_true);
+ fll_error_file_print(data_make->error, F_status_set_fine(status_file), "fl_directory_clone", F_true, arguments.array[i].string, "clone", fll_error_file_type_directory);
*status = F_status_set_error(F_failure);
}
}
status_file = f_file_clone(arguments.array[i].string, destination, F_true, recurse.size_block, recurse.exclusive);
if (F_status_is_error(status_file)) {
- fake_print_message_file(data, data_make->error, F_status_set_fine(status_file), "f_file_clone", arguments.array[i].string, "clone", F_false, F_true);
+ fll_error_file_print(data_make->error, F_status_set_fine(status_file), "f_file_clone", F_true, arguments.array[i].string, "clone", fll_error_file_type_file);
*status = F_status_set_error(F_failure);
}
else if (data.error.verbosity == f_console_verbosity_verbose) {
}
}
else if (F_status_is_error(status_file)) {
- fake_print_message_file(data, data_make->error, F_status_set_fine(status_file), "f_directory_is", arguments.array[i].string, "identify", F_false, F_true);
+ fll_error_file_print(data_make->error, F_status_set_fine(status_file), "f_directory_is", F_true, arguments.array[i].string, "identify", fll_error_file_type_directory);
*status = F_status_set_error(F_failure);
break;
}
// in this case, the destination could be a file, so confirm this.
if (arguments.used == 2) {
- status_file = f_directory_is(arguments.array[total].string);
+ status_file = f_directory_is(arguments.array[1].string);
if (F_status_is_error(status_file)) {
- fake_print_message_file(data, data_make->error, F_status_set_fine(status_file), "f_directory_is", arguments.array[1].string, "identify", F_false, F_true);
+ fll_error_file_print(data_make->error, F_status_set_fine(status_file), "f_directory_is", F_true, arguments.array[1].string, "identify", fll_error_file_type_directory);
+
*status = F_status_set_error(F_failure);
return;
}
status_file = fl_directory_copy(arguments.array[i].string, destination, arguments.array[i].used, destination_length, mode, recurse);
if (F_status_is_error(status_file)) {
- fake_print_message_file(data, data_make->error, F_status_set_fine(status_file), "fl_directory_copy", arguments.array[i].string, "copy", F_false, F_true);
+ fll_error_file_print(data_make->error, F_status_set_fine(status_file), "fl_directory_copy", F_true, arguments.array[i].string, "copy", fll_error_file_type_directory);
*status = F_status_set_error(F_failure);
}
}
status_file = f_file_copy(arguments.array[i].string, destination, mode, recurse.size_block, recurse.exclusive);
if (F_status_is_error(status_file)) {
- fake_print_message_file(data, data_make->error, F_status_set_fine(status_file), "f_file_copy", arguments.array[i].string, "copy", F_false, F_true);
+ fll_error_file_print(data_make->error, F_status_set_fine(status_file), "f_file_copy", F_true, arguments.array[i].string, "copy", fll_error_file_type_file);
*status = F_status_set_error(F_failure);
}
else if (data.error.verbosity == f_console_verbosity_verbose) {
}
}
else if (F_status_is_error(status_file)) {
- fake_print_message_file(data, data_make->error, F_status_set_fine(status_file), "f_directory_is", arguments.array[i].string, "identify", F_false, F_true);
+ fll_error_file_print(data_make->error, F_status_set_fine(status_file), "f_directory_is", F_true, arguments.array[i].string, "identify", fll_error_file_type_directory);
*status = F_status_set_error(F_failure);
break;
}
// in this case, the destination could be a file, so confirm this.
if (arguments.used == 2) {
- status_file = f_directory_is(arguments.array[total].string);
+ status_file = f_directory_is(arguments.array[1].string);
if (F_status_is_error(status_file)) {
fll_error_file_print(data_make->error, F_status_set_fine(*status), "f_directory_is", F_true, arguments.array[1].string, "identify", fll_error_file_type_directory);
}
for (f_array_length_t i = 0; i < total; i++) {
+
destination_length = arguments.array[total].used;
if (existing) {
} // for
if (arguments.used > 2) {
+
// the last file must be a directory.
f_status_t status_file = f_directory_is(arguments.array[arguments.used - 1].string);
*status = F_status_set_error(F_failure);
}
else if (F_status_is_error(status_file)) {
- fake_print_message_file(data, data_make->error, F_status_set_fine(status_file), "f_directory_is", arguments.array[arguments.used - 1].string, "find", F_false, F_true);
+ fll_error_file_print(data_make->error, F_status_set_fine(status_file), "f_directory_is", F_true, arguments.array[arguments.used - 1].string, "find", fll_error_file_type_directory);
*status = F_status_set_error(F_failure);
}
}
else {
+
// when the first file is a directory, then the second, if it exists, must also be a directory.
f_status_t status_file = f_directory_is(arguments.array[0].string);
if (data.error.verbosity != f_console_verbosity_quiet && data_make->error.to.stream) {
fprintf(data_make->error.to.stream, "%c", f_string_eol[0]);
fl_color_print(data_make->error.to.stream, data_make->error.context, "%sThe last file '", data_make->error.prefix);
- fl_color_print(data_make->error.to.stream, data_make->error.notable, "%s", arguments.array[arguments.used - 1].string);
+ fl_color_print(data_make->error.to.stream, data_make->error.notable, "%s", arguments.array[1].string);
fl_color_print(data_make->error.to.stream, data_make->error.context, "' must be a valid directory.%c", f_string_eol[0]);
}
} // for
if (arguments.used > 2) {
+
// the last file must be a directory.
f_status_t status_file = f_directory_is(arguments.array[arguments.used - 1].string);
*status = F_status_set_error(F_failure);
}
else if (F_status_is_error(status_file)) {
- fake_print_message_file(data, data_make->error, F_status_set_fine(status_file), "f_directory_is", arguments.array[arguments.used - 1].string, "find", F_false, F_true);
+ fll_error_file_print(data_make->error, F_status_set_fine(status_file), "f_directory_is", F_true, arguments.array[arguments.used - 1].string, "identify", fll_error_file_type_directory);
*status = F_status_set_error(F_failure);
}
}
else {
+
// when the first file is a directory, then the second, if it exists, must also be a directory.
f_status_t status_file = f_directory_is(arguments.array[0].string);
if (data.error.verbosity != f_console_verbosity_quiet && data_make->error.to.stream) {
fprintf(data_make->error.to.stream, "%c", f_string_eol[0]);
fl_color_print(data_make->error.to.stream, data_make->error.context, "%sThe last file '", data_make->error.prefix);
- fl_color_print(data_make->error.to.stream, data_make->error.notable, "%s", arguments.array[arguments.used - 1].string);
+ fl_color_print(data_make->error.to.stream, data_make->error.notable, "%s", arguments.array[1].string);
fl_color_print(data_make->error.to.stream, data_make->error.context, "' must be a valid directory.%c", f_string_eol[0]);
}
f_status_t status_file = F_none;
for (f_array_length_t i = 1; i < arguments.used; i++) {
+
status_file = f_file_is(arguments.array[i].string, f_file_type_regular, F_false);
if (status_file == F_file_found_not) {
}
else if (F_status_is_error(status_file)) {
if (data.error.verbosity != f_console_verbosity_quiet && data_make->error.to.stream) {
- fake_print_message_file(data, data_make->error, *status, "f_file_is", arguments.array[i].string, "find", F_true, F_true);
+ fll_error_file_print(data_make->error, F_status_set_fine(*status), "f_file_is", F_true, arguments.array[i].string, "find", fll_error_file_type_directory);
}
*status = status_file;
} // for
if (arguments.used > 2) {
+
// the last file must be a directory.
f_status_t status_file = f_directory_is(arguments.array[arguments.used - 1].string);
*status = F_status_set_error(F_failure);
}
else if (F_status_is_error(status_file)) {
- fake_print_message_file(data, data_make->error, F_status_set_fine(status_file), "f_directory_is", arguments.array[arguments.used - 1].string, "find", F_false, F_true);
+ fll_error_file_print(data_make->error, F_status_set_fine(status_file), "f_directory_is", F_true, arguments.array[arguments.used - 1].string, "identify", fll_error_file_type_directory);
*status = F_status_set_error(F_failure);
}
}
else {
+
// when the first file is a directory, then the second, if it exists, must also be a directory.
f_status_t status_file = f_directory_is(arguments.array[0].string);
if (data.error.verbosity != f_console_verbosity_quiet && data_make->error.to.stream) {
fprintf(data_make->error.to.stream, "%c", f_string_eol[0]);
fl_color_print(data_make->error.to.stream, data_make->error.context, "%sThe last file '", data_make->error.prefix);
- fl_color_print(data_make->error.to.stream, data_make->error.notable, "%s", arguments.array[arguments.used - 1].string);
+ fl_color_print(data_make->error.to.stream, data_make->error.notable, "%s", arguments.array[1].string);
fl_color_print(data_make->error.to.stream, data_make->error.context, "' must be a valid directory.%c", f_string_eol[0]);
}
}
#endif // _di_fake_print_error_parameter_too_many_
-#ifndef _di_fake_print_message_file_
- bool fake_print_message_file(const fake_data_t data, const fll_error_print_t error, const f_status_t status, const f_string_t function, const f_string_t name, const f_string_t operation, const bool is_file, const bool fallback) {
- const f_string_t file_or_directory = is_file ? "file" : "directory";
-
- if (status == F_file_found_not) {
- if (data.error.verbosity != f_console_verbosity_quiet) {
- fprintf(error.to.stream, "%c", f_string_eol[0]);
- fl_color_print(error.to.stream, data.error.context, "%s: Failed to find %s '", data.error.prefix, file_or_directory);
- fl_color_print(error.to.stream, data.context.set.notable, "%s", name);
- fl_color_print(error.to.stream, data.error.context, "'.%c", f_string_eol[0]);
- }
-
- return F_false;
- }
-
- if (status == F_file_found) {
- if (data.error.verbosity != f_console_verbosity_quiet) {
- fprintf(error.to.stream, "%c", f_string_eol[0]);
- fl_color_print(error.to.stream, data.error.context, "%s: The %s '", data.error.prefix, file_or_directory);
- fl_color_print(error.to.stream, data.context.set.notable, "%s", name);
- fl_color_print(error.to.stream, data.error.context, "' already exists.%c", f_string_eol[0]);
- }
-
- return F_false;
- }
-
- if (status == F_directory_empty_not) {
- if (data.error.verbosity != f_console_verbosity_quiet) {
- fprintf(error.to.stream, "%c", f_string_eol[0]);
- fl_color_print(error.to.stream, data.error.context, "%s: The %s '", data.error.prefix, file_or_directory);
- fl_color_print(error.to.stream, data.context.set.notable, "%s", name);
- fl_color_print(error.to.stream, data.error.context, "' is not empty.%c", f_string_eol[0]);
- }
-
- return F_false;
- }
-
- if (status == F_parameter) {
- if (data.error.verbosity != f_console_verbosity_quiet) {
- fprintf(error.to.stream, "%c", f_string_eol[0]);
- fl_color_print(error.to.stream, data.error.context, "INTERNAL %s: Invalid parameter when calling ", data.error.prefix);
- fl_color_print(error.to.stream, data.context.set.notable, "%s", function);
- fl_color_print(error.to.stream, data.error.context, "() for the %s '", file_or_directory);
- fl_color_print(error.to.stream, data.context.set.notable, "%s", name);
- fl_color_print(error.to.stream, data.error.context, "'.%c", f_string_eol[0]);
- }
-
- return F_false;
- }
-
- if (status == F_name) {
- if (data.error.verbosity != f_console_verbosity_quiet) {
- fprintf(error.to.stream, "%c", f_string_eol[0]);
- fl_color_print(error.to.stream, data.error.context, "%s: Invalid %s name '", data.error.prefix, file_or_directory);
- fl_color_print(error.to.stream, data.context.set.notable, "%s", name);
- fl_color_print(error.to.stream, data.error.context, "'.%c", f_string_eol[0]);
- }
-
- return F_false;
- }
-
- if (status == F_memory_out) {
- if (data.error.verbosity != f_console_verbosity_quiet) {
- fprintf(error.to.stream, "%c", f_string_eol[0]);
- fl_color_print(error.to.stream, data.error.context, "CRITICAL %s: Unable to allocate memory, while trying to %s %s '", data.error.prefix, operation, file_or_directory);
- fl_color_print(error.to.stream, data.context.set.notable, "%s", name);
- fl_color_print(error.to.stream, data.error.context, "'.%c", f_string_eol[0]);
- }
-
- return F_false;
- }
-
- if (status == F_number_overflow) {
- if (data.error.verbosity != f_console_verbosity_quiet) {
- fprintf(error.to.stream, "%c", f_string_eol[0]);
- fl_color_print(error.to.stream, data.error.context, "%s: Overflow while trying to %s %s '", data.error.prefix, operation, file_or_directory);
- fl_color_print(error.to.stream, data.context.set.notable, "%s", name);
- fl_color_print(error.to.stream, data.error.context, "'.%c", f_string_eol[0]);
- }
-
- return F_false;
- }
-
- if (status == F_directory) {
- if (data.error.verbosity != f_console_verbosity_quiet) {
- fprintf(error.to.stream, "%c", f_string_eol[0]);
- fl_color_print(error.to.stream, data.error.context, "%s: Invalid directory while trying to %s %s '", data.error.prefix, operation, file_or_directory);
- fl_color_print(error.to.stream, data.context.set.notable, "%s", name);
- fl_color_print(error.to.stream, data.error.context, "'.%c", f_string_eol[0]);
- }
-
- return F_false;
- }
-
- if (status == F_access_denied) {
- if (data.error.verbosity != f_console_verbosity_quiet) {
- fprintf(error.to.stream, "%c", f_string_eol[0]);
- fl_color_print(error.to.stream, data.error.context, "%s: Access denied while trying to %s %s '", data.error.prefix, operation, file_or_directory);
- fl_color_print(error.to.stream, data.context.set.notable, "%s", name);
- fl_color_print(error.to.stream, data.error.context, "'.%c", f_string_eol[0]);
- }
-
- return F_false;
- }
-
- if (status == F_loop) {
- if (data.error.verbosity != f_console_verbosity_quiet) {
- fprintf(error.to.stream, "%c", f_string_eol[0]);
- fl_color_print(error.to.stream, data.error.context, "%s: Loop while trying to %s %s '", data.error.prefix, operation, file_or_directory);
- fl_color_print(error.to.stream, data.context.set.notable, "%s", name);
- fl_color_print(error.to.stream, data.error.context, "'.%c", f_string_eol[0]);
- }
-
- return F_false;
- }
-
- if (status == F_prohibited) {
- if (data.error.verbosity != f_console_verbosity_quiet) {
- fprintf(error.to.stream, "%c", f_string_eol[0]);
- fl_color_print(error.to.stream, data.error.context, "%s: Prohibited by system while trying to %s %s '", data.error.prefix, operation, file_or_directory);
- fl_color_print(error.to.stream, data.context.set.notable, "%s", name);
- fl_color_print(error.to.stream, data.error.context, "'.%c", f_string_eol[0]);
- }
-
- return F_false;
- }
-
- if (status == F_access_owner) {
- if (data.error.verbosity != f_console_verbosity_quiet) {
- fprintf(error.to.stream, "%c", f_string_eol[0]);
- fl_color_print(error.to.stream, data.error.context, "%s: Currrent user is not allowed to use the given owner while trying to %s %s '", data.error.prefix, operation, file_or_directory);
- fl_color_print(error.to.stream, data.context.set.notable, "%s", name);
- fl_color_print(error.to.stream, data.error.context, "'.%c", f_string_eol[0]);
- }
-
- return F_false;
- }
-
- if (status == F_access_group) {
- if (data.error.verbosity != f_console_verbosity_quiet) {
- fprintf(error.to.stream, "%c", f_string_eol[0]);
- fl_color_print(error.to.stream, data.error.context, "%s: Currrent user is not allowed to use the given group while trying to %s %s '", data.error.prefix, operation, file_or_directory);
- fl_color_print(error.to.stream, data.context.set.notable, "%s", name);
- fl_color_print(error.to.stream, data.error.context, "'.%c", f_string_eol[0]);
- }
-
- return F_false;
- }
-
- if (is_file) {
- if (status == F_directory_found_not) {
- if (data.error.verbosity != f_console_verbosity_quiet) {
- fprintf(error.to.stream, "%c", f_string_eol[0]);
- fl_color_print(error.to.stream, data.error.context, "%s: Failed to %s %s '", data.error.prefix, operation, file_or_directory);
- fl_color_print(error.to.stream, data.context.set.notable, "%s", name);
- fl_color_print(error.to.stream, data.error.context, "' due to an invalid directory in the path.%c", f_string_eol[0]);
- }
-
- return F_false;
- }
- }
- else {
- if (status == F_directory_found_not) {
- if (data.error.verbosity != f_console_verbosity_quiet) {
- fprintf(error.to.stream, "%c", f_string_eol[0]);
- fl_color_print(error.to.stream, data.error.context, "%s: Failed to %s %s '", data.error.prefix, operation, file_or_directory);
- fl_color_print(error.to.stream, data.context.set.notable, "%s", name);
- fl_color_print(error.to.stream, data.error.context, "' due to an invalid directory in the path.%c", f_string_eol[0]);
- }
-
- return F_false;
- }
-
- if (status == F_failure) {
- if (data.error.verbosity != f_console_verbosity_quiet) {
- fprintf(error.to.stream, "%c", f_string_eol[0]);
- fl_color_print(error.to.stream, data.error.context, "%s: Failed to %s %s '", data.error.prefix, operation, file_or_directory);
- fl_color_print(error.to.stream, data.context.set.notable, "%s", name);
- fl_color_print(error.to.stream, data.error.context, "'.%c", f_string_eol[0]);
- }
-
- return F_false;
- }
- }
-
- if (fll_error_print(data.error, status, function, F_false) == F_unknown && fallback && data.error.verbosity != f_console_verbosity_quiet) {
- fprintf(error.to.stream, "%c", f_string_eol[0]);
- fl_color_print(error.to.stream, data.error.context, "UNKNOWN %s: (", data.error.prefix);
- fl_color_print(error.to.stream, data.context.set.notable, "%llu", status);
- fl_color_print(error.to.stream, data.error.context, ") occurred while trying to %s %s '", operation, file_or_directory);
- fl_color_print(error.to.stream, data.context.set.notable, "%s", name);
- fl_color_print(error.to.stream, data.error.context, "'.%c", f_string_eol[0]);
- }
-
- return F_true;
- }
-#endif // _di_fake_print_message_file_
-
#ifndef _di_fake_print_message_section_operation_failed_
void fake_print_message_section_operation_failed(const fake_data_t data, const fll_error_print_t error, const f_string_static_t buffer, const f_string_range_t section_name, const f_string_range_t operation_name) {
if (data.error.verbosity == f_console_verbosity_quiet || !error.to.stream) return;
#endif // _di_fake_print_error_parameter_too_many_
/**
- * Print file/directory error/warning messages.
- *
- * @todo the fll_file_error_print() needs to be reviewed and possibly changed.
- *
- * @param data
- * The program data.
- * @param error
- * Designates how the section error/warning should be printed.
- * @param status
- * The error status code to report on.
- * @param function
- * The function call that returned the error.
- * @param name
- * The name of the file or directory.
- * @param operation
- * The operation that fails, such as 'create' or 'access'.
- * @param is_file
- * Set to TRUE if this is a file and FALSE if this is a directory.
- * @param fallback
- * Set to F_true to print the fallback error message for unknown errors.
- *
- * @return
- * F_true is returned if the status code has no print message.
- * F_false is returned on successful print of known errors.
- */
-#ifndef _di_fake_print_message_file_
- extern bool fake_print_message_file(const fake_data_t data, const fll_error_print_t error, const f_status_t status, const f_string_t function, const f_string_t name, const f_string_t operation, const bool is_file, const bool fallback) f_gcc_attribute_visibility_internal;
-#endif // _di_fake_print_message_file_
-
-/**
* Print error messages when processing some fakefile section, for a specific line and operation, and that operation failed.
*
* @param data