From: Kevin Day Date: Fri, 8 Oct 2021 02:34:57 +0000 (-0500) Subject: Update: Add F_read_only and F_write_only errors to the file error print function. X-Git-Tag: 0.5.6~19 X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=afba7475ac8fc2fb93596a59fc98a26bcf31de7e;p=fll Update: Add F_read_only and F_write_only errors to the file error print function. Also cleanup the function structure a little. --- diff --git a/level_2/fll_error/c/error.c b/level_2/fll_error/c/error.c index 1a2cc31..3fb8929 100644 --- a/level_2/fll_error/c/error.c +++ b/level_2/fll_error/c/error.c @@ -122,13 +122,13 @@ extern "C" { return F_false; } - if (status == F_file_found) { + if (status == F_file_descriptor) { if (print.verbosity != f_console_verbosity_quiet) { flockfile(print.to.stream); - fl_print_format("%c%[%SUnable to %S %S '%]", print.to.stream, f_string_eol_s[0], print.context, print.prefix, operation, type_name, print.context); + fl_print_format("%c%[%SFile descriptor error while trying to %S %S '%]", print.to.stream, f_string_eol_s[0], print.context, print.prefix, operation, type_name, print.context); fl_print_format("%[%S%]", print.to.stream, print.notable, name, print.notable); - fl_print_format("%[', found.%]%c", print.to.stream, print.context, print.context, f_string_eol_s[0]); + fl_print_format("%['.%]%c", print.to.stream, print.context, print.context, f_string_eol_s[0]); funlockfile(print.to.stream); } @@ -136,13 +136,13 @@ extern "C" { return F_false; } - if (status == F_file_found_not) { + if (status == F_file_descriptor_max) { if (print.verbosity != f_console_verbosity_quiet) { flockfile(print.to.stream); - fl_print_format("%c%[%SUnable to %S %S '%]", print.to.stream, f_string_eol_s[0], print.context, print.prefix, operation, type_name, print.context); + fl_print_format("%c%[%SMax file descriptors reached while trying to %S %S '%]", print.to.stream, f_string_eol_s[0], print.context, print.prefix, operation, type_name, print.context); fl_print_format("%[%S%]", print.to.stream, print.notable, name, print.notable); - fl_print_format("%[', could not find.%]%c", print.to.stream, print.context, print.context, f_string_eol_s[0]); + fl_print_format("%['.%]%c", print.to.stream, print.context, print.context, f_string_eol_s[0]); funlockfile(print.to.stream); } @@ -150,13 +150,13 @@ extern "C" { return F_false; } - if (status == F_file_open) { + if (status == F_file_descriptor_not) { if (print.verbosity != f_console_verbosity_quiet) { flockfile(print.to.stream); - fl_print_format("%c%[%SUnable to %S %S '%]", print.to.stream, f_string_eol_s[0], print.context, print.prefix, operation, type_name, print.context); + fl_print_format("%c%[%SInvalid file descriptor while trying to %S %S '%]", print.to.stream, f_string_eol_s[0], print.context, print.prefix, operation, type_name, print.context); fl_print_format("%[%S%]", print.to.stream, print.notable, name, print.notable); - fl_print_format("%[', already open.%]%c", print.to.stream, print.context, print.context, f_string_eol_s[0]); + fl_print_format("%['.%]%c", print.to.stream, print.context, print.context, f_string_eol_s[0]); funlockfile(print.to.stream); } @@ -164,13 +164,13 @@ extern "C" { return F_false; } - if (status == F_file_descriptor) { + if (status == F_file_empty) { if (print.verbosity != f_console_verbosity_quiet) { flockfile(print.to.stream); - fl_print_format("%c%[%SFile descriptor error while trying to %S %S '%]", print.to.stream, f_string_eol_s[0], print.context, print.prefix, operation, type_name, print.context); + fl_print_format("%c%[%SUnable to %S %S '%]", print.to.stream, f_string_eol_s[0], print.context, print.prefix, operation, type_name, print.context); fl_print_format("%[%S%]", print.to.stream, print.notable, name, print.notable); - fl_print_format("%['.%]%c", print.to.stream, print.context, print.context, f_string_eol_s[0]); + fl_print_format("%[', %s is empty.%]%c", print.to.stream, print.context, type_name, print.context, f_string_eol_s[0]); funlockfile(print.to.stream); } @@ -178,13 +178,13 @@ extern "C" { return F_false; } - if (status == F_file_descriptor_max) { + if (status == F_file_flush) { if (print.verbosity != f_console_verbosity_quiet) { flockfile(print.to.stream); - fl_print_format("%c%[%SMax file descriptors reached while trying to %S %S '%]", print.to.stream, f_string_eol_s[0], print.context, print.prefix, operation, type_name, print.context); + fl_print_format("%c%[%SUnable to %S %S '%]", print.to.stream, f_string_eol_s[0], print.context, print.prefix, operation, type_name, print.context); fl_print_format("%[%S%]", print.to.stream, print.notable, name, print.notable); - fl_print_format("%['.%]%c", print.to.stream, print.context, print.context, f_string_eol_s[0]); + fl_print_format("%[', flush failed.%]%c", print.to.stream, print.context, print.context, f_string_eol_s[0]); funlockfile(print.to.stream); } @@ -192,13 +192,13 @@ extern "C" { return F_false; } - if (status == F_file_descriptor_not) { + if (status == F_file_found) { if (print.verbosity != f_console_verbosity_quiet) { flockfile(print.to.stream); - fl_print_format("%c%[%SInvalid file descriptor while trying to %S %S '%]", print.to.stream, f_string_eol_s[0], print.context, print.prefix, operation, type_name, print.context); + fl_print_format("%c%[%SUnable to %S %S '%]", print.to.stream, f_string_eol_s[0], print.context, print.prefix, operation, type_name, print.context); fl_print_format("%[%S%]", print.to.stream, print.notable, name, print.notable); - fl_print_format("%['.%]%c", print.to.stream, print.context, print.context, f_string_eol_s[0]); + fl_print_format("%[', found.%]%c", print.to.stream, print.context, print.context, f_string_eol_s[0]); funlockfile(print.to.stream); } @@ -206,13 +206,13 @@ extern "C" { return F_false; } - if (status == F_file_empty) { + if (status == F_file_found_not) { if (print.verbosity != f_console_verbosity_quiet) { flockfile(print.to.stream); fl_print_format("%c%[%SUnable to %S %S '%]", print.to.stream, f_string_eol_s[0], print.context, print.prefix, operation, type_name, print.context); fl_print_format("%[%S%]", print.to.stream, print.notable, name, print.notable); - fl_print_format("%[', %s is empty.%]%c", print.to.stream, print.context, type_name, print.context, f_string_eol_s[0]); + fl_print_format("%[', could not find.%]%c", print.to.stream, print.context, print.context, f_string_eol_s[0]); funlockfile(print.to.stream); } @@ -220,13 +220,13 @@ extern "C" { return F_false; } - if (status == F_file_flush) { + if (status == F_file_open) { if (print.verbosity != f_console_verbosity_quiet) { flockfile(print.to.stream); fl_print_format("%c%[%SUnable to %S %S '%]", print.to.stream, f_string_eol_s[0], print.context, print.prefix, operation, type_name, print.context); fl_print_format("%[%S%]", print.to.stream, print.notable, name, print.notable); - fl_print_format("%[', flush failed.%]%c", print.to.stream, print.context, print.context, f_string_eol_s[0]); + fl_print_format("%[', already open.%]%c", print.to.stream, print.context, print.context, f_string_eol_s[0]); funlockfile(print.to.stream); } @@ -290,6 +290,20 @@ extern "C" { return F_false; } + if (status == F_read_only) { + if (print.verbosity != f_console_verbosity_quiet) { + flockfile(print.to.stream); + + fl_print_format("%c%[%SUnable to %S %S '%]", print.to.stream, f_string_eol_s[0], print.context, print.prefix, operation, type_name, print.context); + fl_print_format("%[%S%]", print.to.stream, print.notable, name, print.notable); + fl_print_format("%[', %S is read only.%]%c", print.to.stream, print.context, type_name, print.context, f_string_eol_s[0]); + + funlockfile(print.to.stream); + } + + return F_false; + } + if (status == F_file_seek) { if (print.verbosity != f_console_verbosity_quiet) { flockfile(print.to.stream); @@ -388,6 +402,20 @@ extern "C" { return F_false; } + if (status == F_write_only) { + if (print.verbosity != f_console_verbosity_quiet) { + flockfile(print.to.stream); + + fl_print_format("%c%[%SUnable to %S %S '%]", print.to.stream, f_string_eol_s[0], print.context, print.prefix, operation, type_name, print.context); + fl_print_format("%[%S%]", print.to.stream, print.notable, name, print.notable); + fl_print_format("%[', %S is write only.%]%c", print.to.stream, print.context, type_name, print.context, f_string_eol_s[0]); + + funlockfile(print.to.stream); + } + + return F_false; + } + if (status == F_loop) { if (print.verbosity != f_console_verbosity_quiet) { flockfile(print.to.stream);