This project contains the function fll_file_error_print() for handling common error output.
--- /dev/null
+#include <level_2/file.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef _di_fll_file_error_print_
+ f_return_status fll_file_error_print(FILE *file, const fl_color_context context, const f_string function_name, const f_string file_name, const f_status status) {
+
+ if (status == f_error_allocation || status == f_error_reallocation) {
+ fl_color_print_line(file, context.error, context.reset, "CRITICAL ERROR: Unable to allocate memory.");
+ }
+ else if (status == f_file_not_open) {
+ fl_color_print(file, context.error, context.reset, "INTERNAL ERROR: The file '");
+ fl_color_print(file, context.notable, context.reset, "%s", file_name);
+ fl_color_print_line(file, context.error, context.reset, "' is no longer open.");
+ }
+ else if (status == f_file_error_seek) {
+ fl_color_print(file, context.error, context.reset, "ERROR: A seek error occurred while accessing the file '");
+ fl_color_print(file, context.notable, context.reset, "%s", file_name);
+ fl_color_print_line(file, context.error, context.reset, "'.");
+ }
+ else if (status == f_file_error_read) {
+ fl_color_print(file, context.error, context.reset, "ERROR: A read error occurred while accessing the file '");
+ fl_color_print(file, context.notable, context.reset, "%s", file_name);
+ fl_color_print_line(file, context.error, context.reset, "'.");
+ }
+ else if (status == f_file_not_found) {
+ fl_color_print(file, context.error, context.reset, "ERROR: Unable to find the file '");
+ fl_color_print(file, context.notable, context.reset, "%s", file_name);
+ fl_color_print_line(file, context.error, context.reset, "'.");
+ }
+ else if (status == f_file_error_open) {
+ fl_color_print(file, context.error, context.reset, "ERROR: Unable to open the file '");
+ fl_color_print(file, context.notable, context.reset, "%s", file_name);
+ fl_color_print_line(file, context.error, context.reset, "'.");
+ }
+ else if (status == f_file_error_descriptor) {
+ fl_color_print(file, context.error, context.reset, "ERROR: File descriptor error while trying to open the file '");
+ fl_color_print(file, context.notable, context.reset, "%s", file_name);
+ fl_color_print_line(file, context.error, context.reset, "'.");
+ }
+ else if (status == f_invalid_parameter) {
+ fl_color_print(file, context.error, context.reset, "INTERNAL ERROR: Invalid parameter when calling ");
+ fl_color_print(file, context.notable, context.reset, "%s()", function_name);
+ fl_color_print_line(file, context.error, context.reset, ".");
+ }
+ else if (status == f_number_overflow) {
+ fl_color_print(file, context.error, context.reset, "ERROR: Integer overflow while trying to buffer the file '");
+ fl_color_print(file, context.notable, context.reset, "%s", file_name);
+ fl_color_print_line(file, context.error, context.reset, "'.");
+ }
+ else if (status == f_number_underflow) {
+ fl_color_print(file, context.error, context.reset, "ERROR: Integer underflow while trying to buffer the file '");
+ fl_color_print(file, context.notable, context.reset, "%s", file_name);
+ fl_color_print_line(file, context.error, context.reset, "'.");
+ }
+ else {
+ return f_false;
+ }
+
+ return f_true;
+ }
+#endif // _di_fll_file_error_print_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 2
+ *
+ * Project: File
+ * API Version: 0.5
+ * Licenses: lgplv2.1
+ *
+ * Provides file-related functionality.
+ */
+#ifndef _FLL_file_h
+#define _FLL_file_h
+
+// libc includes
+#include <stdio.h>
+
+// fll-0 includes
+#include <level_0/status.h>
+#include <level_0/memory.h>
+#include <level_0/string.h>
+#include <level_0/type.h>
+#include <level_0/utf.h>
+
+// fll-1 includes
+#include <level_1/color.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Print file error messages.
+ *
+ * @param file
+ * The file to write to, such as f_standard_output or f_standard_error.
+ * @param context
+ * The color context information to use when printing.
+ * @param function_name
+ * The name of the function responsible for the error.
+ * @param file_name
+ * The name of the file with the error.
+ * @param status
+ * The status code representing the error.
+ * The status code should be passed through f_status_set_fine() if it contains error or warning bits.
+ *
+ * @return
+ * f_true if error message was printed.
+ * f_false if no error message was printed.
+ */
+#ifndef _di_fll_file_error_print_
+ extern f_return_status fll_file_error_print(FILE *file, const fl_color_context context, const f_string function_name, const f_string file_name, const f_status status);
+#endif // _di_fll_file_error_print_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // _FLL_file_h
--- /dev/null
+f_type
+f_status
+f_memory
+f_string
+f_utf
+fl_color
--- /dev/null
+# fss-0000
+
+project_name fll_file
+project_level 2
+
+version_major 0
+version_minor 5
+version_micro 0
+
+build_compiler gcc
+build_linker ar
+build_libraries -lc
+build_libraries_fll -lfl_color -lf_utf -lf_memory
+build_sources_library file.c
+build_sources_program
+build_sources_headers file.h
+build_sources_bash
+build_sources_settings
+build_shared yes
+build_static yes
+
+defines_all
+defines_static
+defines_shared
+
+flags_all -z now -g
+flags_shared
+flags_static
+flags_library -fPIC
+flags_program -fPIE
// fll-2 includes
#include <level_2/execute.h>
+#include <level_2/file.h>
#include <level_2/fss_basic_list.h>
#include <level_2/program.h>
#ifndef _di_fss_basic_list_read_print_file_error_
void fss_basic_list_read_print_file_error(const fl_color_context context, const f_string function_name, const f_string file_name, const f_status status) {
- if (status == f_invalid_parameter) {
- fl_color_print(f_standard_error, context.error, context.reset, "INTERNAL ERROR: Invalid parameter when calling ");
- fl_color_print(f_standard_error, context.notable, context.reset, "%s()", function_name);
- fl_color_print_line(f_standard_error, context.error, context.reset, ".");
- }
- else if (status == f_number_overflow) {
- fl_color_print(f_standard_error, context.error, context.reset, "ERROR: Integer overflow while trying to buffer the file '");
- fl_color_print(f_standard_error, context.notable, context.reset, "%s", file_name);
- fl_color_print_line(f_standard_error, context.error, context.reset, "'.");
- }
- else if (status == f_file_not_open) {
- fl_color_print(f_standard_error, context.error, context.reset, "INTERNAL ERROR: The file '");
- fl_color_print(f_standard_error, context.notable, context.reset, "%s", file_name);
- fl_color_print_line(f_standard_error, context.error, context.reset, "' is no longer open.");
- }
- else if (status == f_file_error_seek) {
- fl_color_print(f_standard_error, context.error, context.reset, "ERROR: A seek error occurred while accessing the file '");
- fl_color_print(f_standard_error, context.notable, context.reset, "%s", file_name);
- fl_color_print_line(f_standard_error, context.error, context.reset, "'.");
- }
- else if (status == f_file_error_read) {
- fl_color_print(f_standard_error, context.error, context.reset, "ERROR: A read error occurred while accessing the file '");
- fl_color_print(f_standard_error, context.notable, context.reset, "%s", file_name);
- fl_color_print_line(f_standard_error, context.error, context.reset, "'.");
- }
- else if (status == f_file_not_found) {
- fl_color_print(f_standard_error, context.error, context.reset, "ERROR: Unable to find the file '");
- fl_color_print(f_standard_error, context.notable, context.reset, "%s", file_name);
- fl_color_print_line(f_standard_error, context.error, context.reset, "'.");
- }
- else if (status == f_file_error_open) {
- fl_color_print(f_standard_error, context.error, context.reset, "ERROR: Unable to open the file '");
- fl_color_print(f_standard_error, context.notable, context.reset, "%s", file_name);
- fl_color_print_line(f_standard_error, context.error, context.reset, "'.");
- }
- else if (status == f_file_error_descriptor) {
- fl_color_print(f_standard_error, context.error, context.reset, "ERROR: File descriptor error while trying to open the file '");
- fl_color_print(f_standard_error, context.notable, context.reset, "%s", file_name);
- fl_color_print_line(f_standard_error, context.error, context.reset, "'.");
- }
- else if (status == f_number_overflow) {
- fl_color_print(f_standard_error, context.error, context.reset, "ERROR: Integer overflow while trying to buffer the file '");
- fl_color_print(f_standard_error, context.notable, context.reset, "%s", file_name);
- fl_color_print_line(f_standard_error, context.error, context.reset, "'.");
- }
- else if (status == f_error_allocation || status == f_error_reallocation) {
- fl_color_print_line(f_standard_error, context.error, context.reset, "CRITICAL ERROR: Unable to allocate memory.");
- }
- else {
+ if (fll_file_error_print(f_standard_error, context, function_name, file_name, status) == f_false) {
fl_color_print(f_standard_error, context.error, context.reset, "INTERNAL ERROR: An unhandled error (");
fl_color_print(f_standard_error, context.notable, context.reset, "%u", status);
- fl_color_print(f_standard_error, context.error, context.reset, ") has occured while calling ");
+ fl_color_print(f_standard_error, context.error, context.reset, ") has occurred while calling ");
fl_color_print(f_standard_error, context.notable, context.reset, "%s()", function_name);
fl_color_print_line(f_standard_error, context.error, context.reset, ".");
}
else {
fl_color_print(f_standard_error, context.error, context.reset, "INTERNAL ERROR: An unhandled error (");
fl_color_print(f_standard_error, context.notable, context.reset, "%u", status);
- fl_color_print(f_standard_error, context.error, context.reset, ") has occured while calling ");
+ fl_color_print(f_standard_error, context.error, context.reset, ") has occurred while calling ");
fl_color_print(f_standard_error, context.notable, context.reset, "%s()", function_name);
fl_color_print(f_standard_error, context.error, context.reset, "' for the parameter '");
fl_color_print(f_standard_error, context.notable, context.reset, "--%s", parameter_name);
fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: Unable to allocate memory");
}
else if (status == f_incomplete_utf_on_stop) {
- fl_color_print(f_standard_error, data->context.error, data->context.reset, "ENCODING ERROR: error occured on invalid UTF-8 character at stop position (at ");
+ fl_color_print(f_standard_error, data->context.error, data->context.reset, "ENCODING ERROR: error occurred on invalid UTF-8 character at stop position (at ");
fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%d", input.start);
fl_color_print_line(f_standard_error, data->context.error, data->context.reset, ").");
}
else if (status == f_incomplete_utf_on_eos) {
- fl_color_print(f_standard_error, data->context.error, data->context.reset, "ENCODING ERROR: error occured on invalid UTF-8 character at end of string (at ");
+ fl_color_print(f_standard_error, data->context.error, data->context.reset, "ENCODING ERROR: error occurred on invalid UTF-8 character at end of string (at ");
fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%d", input.start);
fl_color_print_line(f_standard_error, data->context.error, data->context.reset, ").");
}
else {
fl_color_print(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (");
fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%u", status);
- fl_color_print(f_standard_error, data->context.error, data->context.reset, ") has occured while calling ");
+ fl_color_print(f_standard_error, data->context.error, data->context.reset, ") has occurred while calling ");
fl_color_print(f_standard_error, data->context.notable, data->context.reset, "fll_fss_basic_list_read()");
fl_color_print(f_standard_error, data->context.error, data->context.reset, " for the file '");
fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s", filename);
fl_status
fl_string
fll_execute
+fll_file
fll_fss
fll_program
build_compiler gcc
build_linker ar
build_libraries -lc
-build_libraries_fll -lfll_program -lfll_fss -lfll_execute -lfl_string -lfl_status -lfl_fss -lf_conversion -lfl_file -lfl_directory -lfl_console -lfl_color -lf_utf -lf_file -lf_print -lf_pipe -lf_console -lf_memory
+build_libraries_fll -lfll_program -lfll_file -lfll_fss -lfll_execute -lfl_string -lfl_status -lfl_fss -lf_conversion -lfl_file -lfl_directory -lfl_console -lfl_color -lf_utf -lf_file -lf_print -lf_pipe -lf_console -lf_memory
#build_libraries_fll-level -lfll_2 -lfll_1 -lfll_0
#build_libraries_fll-monolithic -lfll
build_sources_library fss_basic_list_read.c private-fss_basic_list_read.c
fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: File descriptor error while trying to open the file '%s'", "-");
}
else {
- fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling f_file_open()", status);
+ fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_open()", status);
}
f_status status2 = f_none;
fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: File descriptor error while trying to open the file '%s'", arguments.argv[data->parameters[fss_basic_list_write_parameter_file].additional.array[0]]);
}
else {
- fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling f_file_open()", status);
+ fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_open()", status);
}
fss_basic_list_write_delete_data(data);
fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Unable to write to the file '%s'", arguments.argv[data->parameters[fss_basic_list_write_parameter_file].additional.array[0]]);
}
else {
- fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fl_file_write()", status);
+ fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling fl_file_write()", status);
}
fss_basic_list_write_delete_data(data);
fl_status
fl_string
fll_execute
+fll_file
fll_fss
fll_program
build_compiler gcc
build_linker ar
build_libraries -lc
-build_libraries_fll -lfll_program -lfll_fss -lfll_execute -lfl_string -lfl_status -lfl_fss -lf_conversion -lfl_file -lfl_directory -lfl_console -lfl_color -lf_utf -lf_file -lf_print -lf_pipe -lf_console -lf_memory
+build_libraries_fll -lfll_program -lfll_file -lfll_fss -lfll_execute -lfl_string -lfl_status -lfl_fss -lf_conversion -lfl_file -lfl_directory -lfl_console -lfl_color -lf_utf -lf_file -lf_print -lf_pipe -lf_console -lf_memory
#build_libraries_fll-level -lfll_2 -lfll_1 -lfll_0
#build_libraries_fll-monolithic -lfll
build_sources_library fss_basic_list_write.c
// fll-2 includes
#include <level_2/execute.h>
+#include <level_2/file.h>
#include <level_2/fss_basic.h>
#include <level_2/program.h>
#ifndef _di_fss_basic_read_print_file_error_
void fss_basic_read_print_file_error(const fl_color_context context, const f_string function_name, const f_string file_name, const f_status status) {
- if (status == f_invalid_parameter) {
- fl_color_print(f_standard_error, context.error, context.reset, "INTERNAL ERROR: Invalid parameter when calling ");
- fl_color_print(f_standard_error, context.notable, context.reset, "%s()", function_name);
- fl_color_print_line(f_standard_error, context.error, context.reset, ".");
- }
- else if (status == f_number_overflow) {
- fl_color_print(f_standard_error, context.error, context.reset, "ERROR: Integer overflow while trying to buffer the file '");
- fl_color_print(f_standard_error, context.notable, context.reset, "%s", file_name);
- fl_color_print_line(f_standard_error, context.error, context.reset, "'.");
- }
- else if (status == f_file_not_open) {
- fl_color_print(f_standard_error, context.error, context.reset, "INTERNAL ERROR: The file '");
- fl_color_print(f_standard_error, context.notable, context.reset, "%s", file_name);
- fl_color_print_line(f_standard_error, context.error, context.reset, "' is no longer open.");
- }
- else if (status == f_file_error_seek) {
- fl_color_print(f_standard_error, context.error, context.reset, "ERROR: A seek error occurred while accessing the file '");
- fl_color_print(f_standard_error, context.notable, context.reset, "%s", file_name);
- fl_color_print_line(f_standard_error, context.error, context.reset, "'.");
- }
- else if (status == f_file_error_read) {
- fl_color_print(f_standard_error, context.error, context.reset, "ERROR: A read error occurred while accessing the file '");
- fl_color_print(f_standard_error, context.notable, context.reset, "%s", file_name);
- fl_color_print_line(f_standard_error, context.error, context.reset, "'.");
- }
- else if (status == f_file_not_found) {
- fl_color_print(f_standard_error, context.error, context.reset, "ERROR: Unable to find the file '");
- fl_color_print(f_standard_error, context.notable, context.reset, "%s", file_name);
- fl_color_print_line(f_standard_error, context.error, context.reset, "'.");
- }
- else if (status == f_file_error_open) {
- fl_color_print(f_standard_error, context.error, context.reset, "ERROR: Unable to open the file '");
- fl_color_print(f_standard_error, context.notable, context.reset, "%s", file_name);
- fl_color_print_line(f_standard_error, context.error, context.reset, "'.");
- }
- else if (status == f_file_error_descriptor) {
- fl_color_print(f_standard_error, context.error, context.reset, "ERROR: File descriptor error while trying to open the file '");
- fl_color_print(f_standard_error, context.notable, context.reset, "%s", file_name);
- fl_color_print_line(f_standard_error, context.error, context.reset, "'.");
- }
- else if (status == f_number_overflow) {
- fl_color_print(f_standard_error, context.error, context.reset, "ERROR: Integer overflow while trying to buffer the file '");
- fl_color_print(f_standard_error, context.notable, context.reset, "%s", file_name);
- fl_color_print_line(f_standard_error, context.error, context.reset, "'.");
- }
- else if (status == f_error_allocation || status == f_error_reallocation) {
- fl_color_print_line(f_standard_error, context.error, context.reset, "CRITICAL ERROR: Unable to allocate memory.");
- }
- else {
+ if (fll_file_error_print(f_standard_error, context, function_name, file_name, status) == f_false) {
fl_color_print(f_standard_error, context.error, context.reset, "INTERNAL ERROR: An unhandled error (");
fl_color_print(f_standard_error, context.notable, context.reset, "%u", status);
- fl_color_print(f_standard_error, context.error, context.reset, ") has occured while calling ");
+ fl_color_print(f_standard_error, context.error, context.reset, ") has occurred while calling ");
fl_color_print(f_standard_error, context.notable, context.reset, "%s()", function_name);
fl_color_print_line(f_standard_error, context.error, context.reset, ".");
}
else {
fl_color_print(f_standard_error, context.error, context.reset, "INTERNAL ERROR: An unhandled error (");
fl_color_print(f_standard_error, context.notable, context.reset, "%u", status);
- fl_color_print(f_standard_error, context.error, context.reset, ") has occured while calling ");
+ fl_color_print(f_standard_error, context.error, context.reset, ") has occurred while calling ");
fl_color_print(f_standard_error, context.notable, context.reset, "%s()", function_name);
fl_color_print(f_standard_error, context.error, context.reset, "' for the parameter '");
fl_color_print(f_standard_error, context.notable, context.reset, "--%s", parameter_name);
fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: Unable to allocate memory");
}
else if (status == f_incomplete_utf_on_stop) {
- fl_color_print(f_standard_error, data->context.error, data->context.reset, "ENCODING ERROR: error occured on invalid UTF-8 character at stop position (at ");
+ fl_color_print(f_standard_error, data->context.error, data->context.reset, "ENCODING ERROR: error occurred on invalid UTF-8 character at stop position (at ");
fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%d", input.start);
fl_color_print_line(f_standard_error, data->context.error, data->context.reset, ").");
}
else if (status == f_incomplete_utf_on_eos) {
- fl_color_print(f_standard_error, data->context.error, data->context.reset, "ENCODING ERROR: error occured on invalid UTF-8 character at end of string (at ");
+ fl_color_print(f_standard_error, data->context.error, data->context.reset, "ENCODING ERROR: error occurred on invalid UTF-8 character at end of string (at ");
fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%d", input.start);
fl_color_print_line(f_standard_error, data->context.error, data->context.reset, ").");
}
else {
fl_color_print(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (");
fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%u", status);
- fl_color_print(f_standard_error, data->context.error, data->context.reset, ") has occured while calling ");
+ fl_color_print(f_standard_error, data->context.error, data->context.reset, ") has occurred while calling ");
fl_color_print(f_standard_error, data->context.notable, data->context.reset, "fll_fss_basic_list_read()");
fl_color_print(f_standard_error, data->context.error, data->context.reset, " for the file '");
fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s", filename);
fl_status
fl_string
fll_execute
+fll_file
fll_fss
fll_program
build_compiler gcc
build_linker ar
build_libraries -lc
-build_libraries_fll -lfll_program -lfll_fss -lfll_execute -lfl_string -lfl_status -lfl_fss -lf_conversion -lfl_file -lfl_directory -lfl_console -lfl_color -lf_utf -lf_file -lf_print -lf_pipe -lf_console -lf_memory
+build_libraries_fll -lfll_program -lfll_file -lfll_fss -lfll_execute -lfl_string -lfl_status -lfl_fss -lf_conversion -lfl_file -lfl_directory -lfl_console -lfl_color -lf_utf -lf_file -lf_print -lf_pipe -lf_console -lf_memory
#build_libraries_fll-level -lfll_2 -lfll_1 -lfll_0
#build_libraries_fll-monolithic -lfll
build_sources_library fss_basic_read.c private-fss_basic_read.c
fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: File descriptor error while trying to open the file '%s'", "-");
}
else {
- fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling f_file_open()", status);
+ fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_open()", status);
}
f_status status2 = f_none;
fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: File descriptor error while trying to open the file '%s'", arguments.argv[data->parameters[fss_basic_write_parameter_file].additional.array[0]]);
}
else {
- fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling f_file_open()", status);
+ fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_open()", status);
}
fss_basic_write_delete_data(data);
fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Unable to write to the file '%s'", arguments.argv[data->parameters[fss_basic_write_parameter_file].additional.array[0]]);
}
else {
- fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fl_file_write()", status);
+ fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling fl_file_write()", status);
}
fss_basic_write_delete_data(data);
fl_status
fl_string
fll_execute
+fll_file
fll_fss
fll_program
build_compiler gcc
build_linker ar
build_libraries -lc
-build_libraries_fll -lfll_program -lfll_fss -lfll_execute -lfl_string -lfl_status -lfl_fss -lf_conversion -lfl_file -lfl_directory -lfl_console -lfl_color -lf_utf -lf_file -lf_print -lf_pipe -lf_console -lf_memory
+build_libraries_fll -lfll_program -lfll_file -lfll_fss -lfll_execute -lfl_string -lfl_status -lfl_fss -lf_conversion -lfl_file -lfl_directory -lfl_console -lfl_color -lf_utf -lf_file -lf_print -lf_pipe -lf_console -lf_memory
#build_libraries_fll-level -lfll_2 -lfll_1 -lfll_0
#build_libraries_fll-monolithic -lfll
build_sources_library fss_basic_write.c
// fll-2 includes
#include <level_2/execute.h>
+#include <level_2/file.h>
#include <level_2/fss_extended_list.h>
#include <level_2/program.h>
#ifndef _di_fss_extended_list_read_print_file_error_
void fss_extended_list_read_print_file_error(const fl_color_context context, const f_string function_name, const f_string file_name, const f_status status) {
- if (status == f_invalid_parameter) {
- fl_color_print(f_standard_error, context.error, context.reset, "INTERNAL ERROR: Invalid parameter when calling ");
- fl_color_print(f_standard_error, context.notable, context.reset, "%s()", function_name);
- fl_color_print_line(f_standard_error, context.error, context.reset, ".");
- }
- else if (status == f_number_overflow) {
- fl_color_print(f_standard_error, context.error, context.reset, "ERROR: Integer overflow while trying to buffer the file '");
- fl_color_print(f_standard_error, context.notable, context.reset, "%s", file_name);
- fl_color_print_line(f_standard_error, context.error, context.reset, "'.");
- }
- else if (status == f_file_not_open) {
- fl_color_print(f_standard_error, context.error, context.reset, "INTERNAL ERROR: The file '");
- fl_color_print(f_standard_error, context.notable, context.reset, "%s", file_name);
- fl_color_print_line(f_standard_error, context.error, context.reset, "' is no longer open.");
- }
- else if (status == f_file_error_seek) {
- fl_color_print(f_standard_error, context.error, context.reset, "ERROR: A seek error occurred while accessing the file '");
- fl_color_print(f_standard_error, context.notable, context.reset, "%s", file_name);
- fl_color_print_line(f_standard_error, context.error, context.reset, "'.");
- }
- else if (status == f_file_error_read) {
- fl_color_print(f_standard_error, context.error, context.reset, "ERROR: A read error occurred while accessing the file '");
- fl_color_print(f_standard_error, context.notable, context.reset, "%s", file_name);
- fl_color_print_line(f_standard_error, context.error, context.reset, "'.");
- }
- else if (status == f_file_not_found) {
- fl_color_print(f_standard_error, context.error, context.reset, "ERROR: Unable to find the file '");
- fl_color_print(f_standard_error, context.notable, context.reset, "%s", file_name);
- fl_color_print_line(f_standard_error, context.error, context.reset, "'.");
- }
- else if (status == f_file_error_open) {
- fl_color_print(f_standard_error, context.error, context.reset, "ERROR: Unable to open the file '");
- fl_color_print(f_standard_error, context.notable, context.reset, "%s", file_name);
- fl_color_print_line(f_standard_error, context.error, context.reset, "'.");
- }
- else if (status == f_file_error_descriptor) {
- fl_color_print(f_standard_error, context.error, context.reset, "ERROR: File descriptor error while trying to open the file '");
- fl_color_print(f_standard_error, context.notable, context.reset, "%s", file_name);
- fl_color_print_line(f_standard_error, context.error, context.reset, "'.");
- }
- else if (status == f_number_overflow) {
- fl_color_print(f_standard_error, context.error, context.reset, "ERROR: Integer overflow while trying to buffer the file '");
- fl_color_print(f_standard_error, context.notable, context.reset, "%s", file_name);
- fl_color_print_line(f_standard_error, context.error, context.reset, "'.");
- }
- else if (status == f_error_allocation || status == f_error_reallocation) {
- fl_color_print_line(f_standard_error, context.error, context.reset, "CRITICAL ERROR: Unable to allocate memory.");
- }
- else {
+ if (fll_file_error_print(f_standard_error, context, function_name, file_name, status) == f_false) {
fl_color_print(f_standard_error, context.error, context.reset, "INTERNAL ERROR: An unhandled error (");
fl_color_print(f_standard_error, context.notable, context.reset, "%u", status);
- fl_color_print(f_standard_error, context.error, context.reset, ") has occured while calling ");
+ fl_color_print(f_standard_error, context.error, context.reset, ") has occurred while calling ");
fl_color_print(f_standard_error, context.notable, context.reset, "%s()", function_name);
fl_color_print_line(f_standard_error, context.error, context.reset, ".");
}
fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: Unable to allocate memory");
}
else if (status == f_incomplete_utf_on_stop) {
- fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ENCODING ERROR: error occured on invalid UTF-8 character at stop position (at %d).", input.start);
+ fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ENCODING ERROR: error occurred on invalid UTF-8 character at stop position (at %d).", input.start);
}
else if (status == f_incomplete_utf_on_eos) {
- fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ENCODING ERROR: error occured on invalid UTF-8 character at end of string (at %d).", input.start);
+ fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ENCODING ERROR: error occurred on invalid UTF-8 character at end of string (at %d).", input.start);
}
else {
- fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fll_fss_extended_list_read() for the file '%s'", status, filename);
+ fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling fll_fss_extended_list_read() for the file '%s'", status, filename);
}
fss_extended_list_read_delete_data(data);
fl_status
fl_string
fll_execute
+fll_file
fll_fss
fll_program
build_compiler gcc
build_linker ar
build_libraries -lc
-build_libraries_fll -lfll_program -lfll_fss -lfll_execute -lfl_string -lfl_status -lfl_fss -lf_conversion -lfl_file -lfl_directory -lfl_console -lfl_color -lf_utf -lf_file -lf_print -lf_pipe -lf_console -lf_memory
+build_libraries_fll -lfll_program -lfll_file -lfll_fss -lfll_execute -lfl_string -lfl_status -lfl_fss -lf_conversion -lfl_file -lfl_directory -lfl_console -lfl_color -lf_utf -lf_file -lf_print -lf_pipe -lf_console -lf_memory
#build_libraries_fll-level -lfll_2 -lfll_1 -lfll_0
#build_libraries_fll-monolithic -lfll
build_sources_library fss_extended_list_read.c private-fss_extended_list_read.c
// fll-2 includes
#include <level_2/execute.h>
+#include <level_2/file.h>
#include <level_2/fss_extended.h>
#include <level_2/program.h>
#ifndef _di_fss_extended_read_print_file_error_
void fss_extended_read_print_file_error(const fl_color_context context, const f_string function_name, const f_string file_name, const f_status status) {
- if (status == f_invalid_parameter) {
- fl_color_print(f_standard_error, context.error, context.reset, "INTERNAL ERROR: Invalid parameter when calling ");
- fl_color_print(f_standard_error, context.notable, context.reset, "%s()", function_name);
- fl_color_print_line(f_standard_error, context.error, context.reset, ".");
- }
- else if (status == f_number_overflow) {
- fl_color_print(f_standard_error, context.error, context.reset, "ERROR: Integer overflow while trying to buffer the file '");
- fl_color_print(f_standard_error, context.notable, context.reset, "%s", file_name);
- fl_color_print_line(f_standard_error, context.error, context.reset, "'.");
- }
- else if (status == f_file_not_open) {
- fl_color_print(f_standard_error, context.error, context.reset, "INTERNAL ERROR: The file '");
- fl_color_print(f_standard_error, context.notable, context.reset, "%s", file_name);
- fl_color_print_line(f_standard_error, context.error, context.reset, "' is no longer open.");
- }
- else if (status == f_file_error_seek) {
- fl_color_print(f_standard_error, context.error, context.reset, "ERROR: A seek error occurred while accessing the file '");
- fl_color_print(f_standard_error, context.notable, context.reset, "%s", file_name);
- fl_color_print_line(f_standard_error, context.error, context.reset, "'.");
- }
- else if (status == f_file_error_read) {
- fl_color_print(f_standard_error, context.error, context.reset, "ERROR: A read error occurred while accessing the file '");
- fl_color_print(f_standard_error, context.notable, context.reset, "%s", file_name);
- fl_color_print_line(f_standard_error, context.error, context.reset, "'.");
- }
- else if (status == f_file_not_found) {
- fl_color_print(f_standard_error, context.error, context.reset, "ERROR: Unable to find the file '");
- fl_color_print(f_standard_error, context.notable, context.reset, "%s", file_name);
- fl_color_print_line(f_standard_error, context.error, context.reset, "'.");
- }
- else if (status == f_file_error_open) {
- fl_color_print(f_standard_error, context.error, context.reset, "ERROR: Unable to open the file '");
- fl_color_print(f_standard_error, context.notable, context.reset, "%s", file_name);
- fl_color_print_line(f_standard_error, context.error, context.reset, "'.");
- }
- else if (status == f_file_error_descriptor) {
- fl_color_print(f_standard_error, context.error, context.reset, "ERROR: File descriptor error while trying to open the file '");
- fl_color_print(f_standard_error, context.notable, context.reset, "%s", file_name);
- fl_color_print_line(f_standard_error, context.error, context.reset, "'.");
- }
- else if (status == f_number_overflow) {
- fl_color_print(f_standard_error, context.error, context.reset, "ERROR: Integer overflow while trying to buffer the file '");
- fl_color_print(f_standard_error, context.notable, context.reset, "%s", file_name);
- fl_color_print_line(f_standard_error, context.error, context.reset, "'.");
- }
- else if (status == f_error_allocation || status == f_error_reallocation) {
- fl_color_print_line(f_standard_error, context.error, context.reset, "CRITICAL ERROR: Unable to allocate memory.");
- }
- else {
+ if (fll_file_error_print(f_standard_error, context, function_name, file_name, status) == f_false) {
fl_color_print(f_standard_error, context.error, context.reset, "INTERNAL ERROR: An unhandled error (");
fl_color_print(f_standard_error, context.notable, context.reset, "%u", status);
- fl_color_print(f_standard_error, context.error, context.reset, ") has occured while calling ");
+ fl_color_print(f_standard_error, context.error, context.reset, ") has occurred while calling ");
fl_color_print(f_standard_error, context.notable, context.reset, "%s()", function_name);
fl_color_print_line(f_standard_error, context.error, context.reset, ".");
}
else {
fl_color_print(f_standard_error, context.error, context.reset, "INTERNAL ERROR: An unhandled error (");
fl_color_print(f_standard_error, context.notable, context.reset, "%u", status);
- fl_color_print(f_standard_error, context.error, context.reset, ") has occured while calling ");
+ fl_color_print(f_standard_error, context.error, context.reset, ") has occurred while calling ");
fl_color_print(f_standard_error, context.notable, context.reset, "%s()", function_name);
fl_color_print(f_standard_error, context.error, context.reset, "' for the parameter '");
fl_color_print(f_standard_error, context.notable, context.reset, "--%s", parameter_name);
fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "CRITICAL ERROR: Unable to allocate memory");
}
else if (status == f_incomplete_utf_on_stop) {
- fl_color_print(f_standard_error, data->context.error, data->context.reset, "ENCODING ERROR: error occured on invalid UTF-8 character at stop position (at ");
+ fl_color_print(f_standard_error, data->context.error, data->context.reset, "ENCODING ERROR: error occurred on invalid UTF-8 character at stop position (at ");
fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%d", input.start);
fl_color_print_line(f_standard_error, data->context.error, data->context.reset, ").");
}
else if (status == f_incomplete_utf_on_eos) {
- fl_color_print(f_standard_error, data->context.error, data->context.reset, "ENCODING ERROR: error occured on invalid UTF-8 character at end of string (at ");
+ fl_color_print(f_standard_error, data->context.error, data->context.reset, "ENCODING ERROR: error occurred on invalid UTF-8 character at end of string (at ");
fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%d", input.start);
fl_color_print_line(f_standard_error, data->context.error, data->context.reset, ").");
}
else {
fl_color_print(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (");
fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%u", status);
- fl_color_print(f_standard_error, data->context.error, data->context.reset, ") has occured while calling ");
+ fl_color_print(f_standard_error, data->context.error, data->context.reset, ") has occurred while calling ");
fl_color_print(f_standard_error, data->context.notable, data->context.reset, "fll_fss_extended_list_read()");
fl_color_print(f_standard_error, data->context.error, data->context.reset, " for the file '");
fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s", filename);
fl_status
fl_string
fll_execute
+fll_file
fll_fss
fll_program
build_compiler gcc
build_linker ar
build_libraries -lc
-build_libraries_fll -lfll_program -lfll_fss -lfll_execute -lfl_string -lfl_status -lfl_fss -lf_conversion -lfl_file -lfl_directory -lfl_console -lfl_color -lf_utf -lf_file -lf_print -lf_pipe -lf_console -lf_memory
+build_libraries_fll -lfll_program -lfll_file -lfll_fss -lfll_execute -lfl_string -lfl_status -lfl_fss -lf_conversion -lfl_file -lfl_directory -lfl_console -lfl_color -lf_utf -lf_file -lf_print -lf_pipe -lf_console -lf_memory
#build_libraries_fll-level -lfll_2 -lfll_1 -lfll_0
#build_libraries_fll-monolithic -lfll
build_sources_library fss_extended_read.c private-fss_extended_read.c
fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling f_console_parameter_process().");
}
else {
- fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling f_console_parameter_process().", status);
+ fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_console_parameter_process().", status);
}
fss_extended_write_delete_data(data);
fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: File descriptor error while trying to open the file '%s'", "-");
}
else {
- fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling f_file_open()", status);
+ fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_open()", status);
}
f_status status2 = f_none;
fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: File descriptor error while trying to open the file '%s'", arguments.argv[data->parameters[fss_extended_write_parameter_file].additional.array[0]]);
}
else {
- fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling f_file_open()", status);
+ fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_open()", status);
}
fss_extended_write_delete_data(data);
fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: Unable to write to the file '%s'", arguments.argv[data->parameters[fss_extended_write_parameter_file].additional.array[0]]);
}
else {
- fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occured while calling fl_file_write()", status);
+ fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling fl_file_write()", status);
}
fss_extended_write_delete_data(data);
fl_status
fl_string
fll_execute
+fll_file
fll_fss
fll_program
build_compiler gcc
build_linker ar
build_libraries -lc
-build_libraries_fll -lfll_program -lfll_fss -lfll_execute -lfl_string -lfl_status -lfl_fss -lf_conversion -lfl_file -lfl_directory -lfl_color -lf_utf -lf_file -lf_print -lf_pipe -lf_console -lf_memory
+build_libraries_fll -lfll_program -lfll_file -lfll_fss -lfll_execute -lfl_string -lfl_status -lfl_fss -lf_conversion -lfl_file -lfl_directory -lfl_color -lf_utf -lf_file -lf_print -lf_pipe -lf_console -lf_memory
#build_libraries_fll-level -lfll_2 -lfll_1 -lfll_0
#build_libraries_fll-monolithic -lfll
build_sources_library fss_extended_write.c
fl_string
fl_utf
fll_execute
+fll_file
fll_fss
fll_program
fll_status
build_compiler gcc
build_linker ar
build_libraries -lc
-build_libraries_fll -lfll_status -lfll_program -lfll_fss -lfll_execute -lfl_utf -lfl_string -lfl_status -lfl_fss -lfl_file -lfl_directory -lfl_console -lfl_color -lf_utf -lf_print -lf_pipe -lf_file -lf_conversion -lf_console -lf_memory
+build_libraries_fll -lfll_program -lfll_file -lfll_fss -lfll_execute -lfll_status -lfl_utf -lfl_string -lfl_status -lfl_fss -lfl_file -lfl_directory -lfl_console -lfl_color -lf_utf -lf_print -lf_pipe -lf_file -lf_conversion -lf_console -lf_memory
#build_libraries_fll-level -lfll_2 -lfll_1 -lfll_0
#build_libraries_fll-monolithic -lfll
build_sources_library fss_status_code.c private-fss_status_code.c