From: Kevin Day Date: Mon, 4 May 2020 11:11:59 +0000 (-0500) Subject: Update: Redesign f_file and fl_file functions, simplifying f_file_position X-Git-Tag: 0.5.0~293 X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=f69e57a;p=fll Update: Redesign f_file and fl_file functions, simplifying f_file_position Redesign the logic behind the f_file and fl_file functions to favor the buffer->used append strategy. Remove f_file_read_range(), something similar can be added later if need be. Povide f_file_reat_until(), that functions similar to f_file_read_at(), except the file position is not automatically set. Using f_file_reat_until() is more efficient in array loops because it does not check the file position every execution. Add f_macro_file_seek_data() and f_macro_file_seek_hole() to support the newer seek modes: SEEK_DATA and SEEK_HOLE. The f_file_position structure is simplified. The file position should only be for file related code and having buffer in there is just plain wrong. The structure is further simplified in its property names. Remove unnecessary invalid parameter checks. Add f_file_default_write_size define. --- diff --git a/level_0/f_file/c/file.c b/level_0/f_file/c/file.c index ca2f86e..485cd92 100644 --- a/level_0/f_file/c/file.c +++ b/level_0/f_file/c/file.c @@ -177,145 +177,116 @@ extern "C" { buffer->used += result; } - if (feof(file->address)) { - return f_none_on_eof; - } + if (feof(file->address)) return f_none_on_eof; return f_none; } #endif // _di_f_file_read_ -#ifndef _di_f_file_read_range_ - f_return_status f_file_read_range(f_file *file, f_string_dynamic *buffer, const f_string_length buffer_start, const f_string_length total_elements) { +#ifndef _di_f_file_read_at_ + f_return_status f_file_read_at(f_file *file, f_string_dynamic *buffer, const f_file_position position) { #ifndef _di_level_0_parameter_checking_ if (file == 0) return f_status_set_error(f_invalid_parameter); if (file->size_chunk == 0) return f_status_set_error(f_invalid_parameter); if (file->size_block == 0) return f_status_set_error(f_invalid_parameter); if (buffer->used >= buffer->size) return f_status_set_error(f_invalid_parameter); - if (buffer_start < 0) return f_status_set_error(f_invalid_parameter); - if (total_elements == 0) return f_status_set_error(f_invalid_parameter); // when the available buffer size is smaller than the total elements, then there is not enough allocated memory available to read the file. - if (total_elements > 0) { - if (buffer_start + total_elements > buffer->size) return f_status_set_error(f_invalid_parameter); + if (position.total > 0) { + if (buffer->used + position.total > buffer->size) return f_status_set_error(f_invalid_parameter); + } + else { + if (buffer->used + (file->size_chunk * file->size_block) > buffer->size) return f_status_set_error(f_invalid_parameter); } #endif // _di_level_0_parameter_checking_ if (file->address == 0) return f_status_set_error(f_file_not_open); + // first seek to 'where' we need to begin the read. + long current_file_position = ftell(file->address); + + if (current_file_position == -1) return f_status_set_error(f_file_error_seek); + int result = 0; - if (total_elements == 0) { - result = fread(buffer->string + buffer_start, file->size_chunk, file->size_block, file->address); + if (current_file_position > position.start) { + result = f_macro_file_seek_to(file->address, file->size_chunk * (0 - (current_file_position - position.start))); + } + else if (current_file_position < position.start) { + result = f_macro_file_seek_to(file->address, file->size_chunk * (position.start - current_file_position)); + } + + if (result != 0) return f_status_set_error(f_file_error_seek); + + // now do the actual read + if (position.total == 0) { + result = fread(buffer->string + buffer->used, file->size_chunk, file->size_block, file->address); } else { - result = fread(buffer->string + buffer_start, file->size_chunk, total_elements, file->address); + result = fread(buffer->string + buffer->used, file->size_chunk, position.total, file->address); } if (file->address == 0) return f_status_set_error(f_file_error_read); if (ferror(file->address) != 0) return f_status_set_error(f_file_error_read); - f_string_length bytes_total; + f_number_unsigned bytes_total; if (file->size_chunk > 1) { - bytes_total = result * file->size_chunk; + buffer->used += result * file->size_chunk; } else { - bytes_total = result; - } - - // Save how much of our allocated buffer is actually used. - if (buffer_start + bytes_total > buffer->used) { - buffer->used = buffer_start + bytes_total; - } - - // Append an EOS only when the total elements were set to 0. - if (total_elements == 0) { - buffer->string[buffer->used] = f_string_eos; + buffer->used += result; } - // Make sure to communicate that we are done without a problem and the EOF was reached. - if (feof(file->address)) { - return f_none_on_eof; - } + if (feof(file->address)) return f_none_on_eof; return f_none; } -#endif // _di_f_file_read_range_ +#endif // _di_f_file_read_at_ -#ifndef _di_f_file_read_at_ - f_return_status f_file_read_at(f_file *file, f_string_dynamic *buffer, const f_file_position position) { +#ifndef _di_f_file_read_until_ + f_return_status f_file_read_until(f_file *file, f_string_dynamic *buffer, const f_string_length total) { #ifndef _di_level_0_parameter_checking_ if (file == 0) return f_status_set_error(f_invalid_parameter); if (file->size_chunk == 0) return f_status_set_error(f_invalid_parameter); if (file->size_block == 0) return f_status_set_error(f_invalid_parameter); if (buffer->used >= buffer->size) return f_status_set_error(f_invalid_parameter); - if (position.buffer_start < 0) return f_status_set_error(f_invalid_parameter); - if (position.file_start < 0) return f_status_set_error(f_invalid_parameter); - if (position.total_elements < 0) return f_status_set_error(f_invalid_parameter); // when the available buffer size is smaller than the total elements, then there is not enough allocated memory available to read the file. - if (position.total_elements > 0) { - if (position.buffer_start + position.total_elements > buffer->size) return f_status_set_error(f_invalid_parameter); + if (total > 0) { + if (buffer->used + total > buffer->size) return f_status_set_error(f_invalid_parameter); + } + else { + if (buffer->used + (file->size_chunk * file->size_block) > buffer->size) return f_status_set_error(f_invalid_parameter); } #endif // _di_level_0_parameter_checking_ if (file->address == 0) return f_status_set_error(f_file_not_open); - // first seek to 'where' we need to begin the read. - unsigned long current_file_position = ftell(file->address); - - if (current_file_position == (unsigned long) -1) return f_status_set_error(f_file_error_seek); - - int result = 0; - - if (current_file_position > position.file_start) { - result = f_macro_file_seek_to(file->address, file->size_chunk * (0 - (current_file_position - position.file_start))); - } - else if (current_file_position < position.file_start) { - result = f_macro_file_seek_to(file->address, file->size_chunk * (position.file_start - current_file_position)); - } - - if (result != 0) return f_status_set_error(f_file_error_seek); + int result; - // now do the actual read - if (position.total_elements == 0) { - result = fread(buffer->string + position.buffer_start, file->size_chunk, file->size_block, file->address); + if (total == 0) { + result = fread(buffer->string + buffer->used, file->size_chunk, file->size_block, file->address); } else { - result = fread(buffer->string + position.buffer_start, file->size_chunk, position.total_elements, file->address); + result = fread(buffer->string + buffer->used, file->size_chunk, total, file->address); } if (file->address == 0) return f_status_set_error(f_file_error_read); if (ferror(file->address) != 0) return f_status_set_error(f_file_error_read); - f_number_unsigned bytes_total; - if (file->size_chunk > 1) { - bytes_total = result * file->size_chunk; + buffer->used += result * file->size_chunk; } else { - bytes_total = result; - } - - // now save how much of our allocated buffer is actually used. - // also make sure that we aren't making used space vanish. - if (position.buffer_start + bytes_total > buffer->used) { - buffer->used = position.buffer_start + bytes_total; + buffer->used += result; } - // append an EOS only when the total elements were set to 0. - if (position.total_elements == 0) { - buffer->string[buffer->used] = f_string_eos; - } - - if (feof(file->address)) { - return f_none_on_eof; - } + if (feof(file->address)) return f_none_on_eof; return f_none; } -#endif // _di_f_file_read_at_ +#endif // _di_f_file_read_until_ #ifndef _di_f_file_stat_ f_return_status f_file_stat(const f_string file_name, struct stat *file_stat) { diff --git a/level_0/f_file/c/file.h b/level_0/f_file/c/file.h index 355f9f6..6e18b55 100644 --- a/level_0/f_file/c/file.h +++ b/level_0/f_file/c/file.h @@ -38,8 +38,9 @@ extern "C" { typedef f_string f_file_mode; typedef mode_t f_file_mask; - #define f_file_default_read_size 8192 // default to 8k read sizes. - #define f_file_max_path_length 1024 + #define f_file_default_read_size 8192 // default to 8k read sizes. + #define f_file_default_write_size 8192 // default to 8k write sizes. + #define f_file_max_path_length 1024 #endif // _di_f_file_types_ /** @@ -60,13 +61,17 @@ extern "C" { * The fseek() function parameters can be confusing, so provide a hopefully more readibly code via these macros. * * The f_macro_file_seek_begin() sets the file pointer from this many bytes from the beginning of the file. - * The f_macro_file_seek_to() sets the file pointer from this many bytes relative to the current position. + * The f_macro_file_seek_data() sets the file pointer from this many bytes from the end of the file, relative to the next data. * The f_macro_file_seek_end() sets the file pointer from this many bytes from the end of the file. + * The f_macro_file_seek_hole() sets the file pointer from this many bytes from the end of the file, relative to the next hole. + * The f_macro_file_seek_to() sets the file pointer from this many bytes relative to the current position. */ #ifndef _di_f_file_seeks_ #define f_macro_file_seek_begin(file, bytes) fseek(file, bytes, SEEK_SET) - #define f_macro_file_seek_to(file, bytes) fseek(file, bytes, SEEK_CUR) + #define f_macro_file_seek_data(file, bytes) fseek(file, bytes, SEEK_DATA) #define f_macro_file_seek_end(file) fseek(file, bytes, SEEK_END) + #define f_macro_file_seek_hole(file, bytes) fseek(file, bytes, SEEK_HOLE) + #define f_macro_file_seek_to(file, bytes) fseek(file, bytes, SEEK_CUR) #endif // _di_f_file_seeks_ /** @@ -95,18 +100,16 @@ extern "C" { * * This is commonly used to instruct functions how to buffer and use a file. * - * buffer_start: Designate where to start writing to the buffer. - * file_start: The positions where to begin reading the file. - * total_elements: The total number of elements to read from the file into the buffer (set to 0 to read entire file). + * start: The positions where to begin reading the file. + * total: The total number of elements to read from the file into the buffer (set to 0 to read entire file). */ #ifndef _di_f_file_position_ typedef struct { - f_string_length buffer_start; - f_string_length file_start; - f_string_length total_elements; + f_string_length start; + f_string_length total; } f_file_position; - #define f_file_position_initialize { 0, 0, 0 } + #define f_file_position_initialize { 0, 0 } #endif // _di_f_file_position_ /** @@ -230,9 +233,9 @@ extern "C" { */ #ifndef _di_f_macro_file_reset_position_ #define f_macro_file_reset_position(position, file) \ - if (position.total_elements == 0) { \ + if (position.total == 0) { \ fseek(file.address, 0L, SEEK_END); \ - position.total_elements = ftell(file.address); \ + position.total = ftell(file.address); \ fseek(file.address, 0L, SEEK_SET); \ } #endif // _di_f_macro_file_reset_position_ @@ -371,45 +374,47 @@ extern "C" { #endif // _di_f_file_read_ /** - * Read until a single block is filled or EOF is reached, storing it into a specific range within the buffer. + * Read until a single block is filled or EOF is reached, specified by the given range within the file, storing it in the buffer. * * This does not allocate space to the buffer, so be sure enough space exists (file->size_chunk * file->size_block). * + * Will auto-seek file position to position.start. + * (The file is assumed to already be in the position.start position.) + * * @param file * The file to read. * @param buffer * The buffer the file is being read into. - * @param buffer_start - * The start position of the buffer. - * @param total_elements - * The total elements to read. - * When set to 0, this will read until the entire buffer is filled or the EOF is reached. + * @param position + * The file position information. + * When position.total_elemenets is set to 0, this will read until the entire buffer is filled or the EOF is reached. * * @return * f_none on success. * f_none_on_eof on success and EOF was reached. * f_file_not_open (with error bit) if file is not open. - * f_file_error_read (with error bit) if file read failed. * f_invalid_parameter (with error bit) if a parameter is invalid. + * + * @see f_file_read_until() */ -#ifndef _di_f_file_read_range_ - extern f_return_status f_file_read_range(f_file *file, f_string_dynamic *buffer, const f_string_length buffer_start, const f_string_length total_elements); -#endif // _di_f_file_read_range_ +#ifndef _di_f_file_read_at_ + extern f_return_status f_file_read_at(f_file *file, f_string_dynamic *buffer, const f_file_position position); +#endif // _di_f_file_read_at_ /** - * Read until a single block is filled or EOF is reached, specified by the given range within the file, storing it in the buffer. + * Read until a single block is filled or EOF is reached, appending it to the buffer. * * This does not allocate space to the buffer, so be sure enough space exists (file->size_chunk * file->size_block). * - * Will auto-seek file position to position.file_start. + * Will not auto-seek file position. * * @param file * The file to read. * @param buffer * The buffer the file is being read into. - * @param position - * The file position information. - * When position.total_elemenets is set to 0, this will read until the entire buffer is filled or the EOF is reached. + * @param total + * The total elements to read. + * When set to 0, this will read until the entire buffer is filled or the EOF is reached. * * @return * f_none on success. @@ -418,10 +423,12 @@ extern "C" { * f_file_error_seek (with error bit) if file seek failed. * f_file_error_read (with error bit) if file read failed. * f_invalid_parameter (with error bit) if a parameter is invalid. + * + * @see f_file_read_at() */ -#ifndef _di_f_file_read_at_ - extern f_return_status f_file_read_at(f_file *file, f_string_dynamic *buffer, const f_file_position position); -#endif // _di_f_file_read_at_ +#ifndef _di_f_file_read_until_ + extern f_return_status f_file_read_until(f_file *file, f_string_dynamic *buffer, const f_string_length total); +#endif // _di_f_file_read_until_ /** * Read statistics of a file. diff --git a/level_1/fl_file/c/file.c b/level_1/fl_file/c/file.c index b70dd02..2517a3e 100644 --- a/level_1/fl_file/c/file.c +++ b/level_1/fl_file/c/file.c @@ -46,9 +46,6 @@ extern "C" { #ifndef _di_level_1_parameter_checking_ if (file == 0) return f_status_set_error(f_invalid_parameter); if (buffer == 0) return f_status_set_error(f_invalid_parameter); - if (position.buffer_start < 0) return f_status_set_error(f_invalid_parameter); - if (position.file_start < 0) return f_status_set_error(f_invalid_parameter); - if (position.total_elements < 0) return f_status_set_error(f_invalid_parameter); #endif // _di_level_1_parameter_checking_ if (file->address == 0) return f_status_set_error(f_file_not_open); @@ -58,16 +55,29 @@ extern "C" { f_number_unsigned bytes_total; - // when total_elements is 0, this means the file read will until EOF is reached. - if (position.total_elements == 0) { + // when total is 0, this means the file read will until EOF is reached. + if (position.total == 0) { infinite = f_true; bytes_total = file->size_block * file->size_chunk; } else { - bytes_total = position.total_elements * file->size_chunk; + bytes_total = position.total * file->size_chunk; } - do { + if (buffer->used + bytes_total > buffer->size) { + if (buffer->used + bytes_total > f_string_max_size) return f_status_set_error(f_string_too_large); + + f_macro_string_dynamic_resize(status, (*buffer), buffer->used + bytes_total); + + if (f_status_is_error(status)) return status; + } + + status = f_file_read_at(file, buffer, position); + + if (f_status_is_error(status)) return status; + if (status == f_none_on_eof) return status; + + while (infinite) { if (buffer->used + bytes_total > buffer->size) { if (buffer->used + bytes_total > f_string_max_size) return f_status_set_error(f_string_too_large); @@ -76,11 +86,11 @@ extern "C" { if (f_status_is_error(status)) return status; } - status = f_file_read_at(file, buffer, position); + status = f_file_read_until(file, buffer, 0); if (f_status_is_error(status)) return status; if (status == f_none_on_eof) break; - } while (infinite); + } // while return status; } @@ -94,11 +104,11 @@ extern "C" { if (file->address == 0) return f_status_set_error(f_file_not_open); - size_t size = 0; + size_t written = 0; - size = fwrite(buffer.string, file->size_chunk, buffer.used, file->address); + written = fwrite(buffer.string, file->size_chunk, buffer.used, file->address); - if (size < buffer.used * file->size_chunk) return f_status_set_error(f_file_error_write); + if (written < buffer.used * file->size_chunk) return f_status_set_error(f_file_error_write); return f_none; } @@ -113,13 +123,13 @@ extern "C" { if (file->address == 0) return f_file_not_open; - size_t size = 0; + size_t written = 0; - f_string_length total = buffer.used - (position.stop - position.start + 1); + const f_string_length total = buffer.used - (position.stop - position.start + 1); - size = fwrite(buffer.string + position.start, file->size_chunk, total, file->address); + written = fwrite(buffer.string + position.start, file->size_chunk, total, file->address); - if (size < total * file->size_chunk) return f_status_set_error(f_file_error_write); + if (written < total * file->size_chunk) return f_status_set_error(f_file_error_write); return f_none; } diff --git a/level_1/fl_fss/c/fss.c b/level_1/fl_fss/c/fss.c index 7e11b50..e0f37d2 100644 --- a/level_1/fl_fss/c/fss.c +++ b/level_1/fl_fss/c/fss.c @@ -180,7 +180,7 @@ extern "C" { f_status status = f_none; f_string_dynamic buffer = f_string_dynamic_initialize; - f_file_position length = f_file_position_initialize; + f_file_position position = f_file_position_initialize; // make sure we are in the proper length in the file { @@ -190,16 +190,16 @@ extern "C" { } // 1: Prepare the buffer to handle a size of f_fss_max_header_length - length.total_elements = f_fss_max_header_length; + position.total = f_fss_max_header_length; - f_macro_string_dynamic_adjust(status, buffer, length.total_elements + 1); + f_macro_string_dynamic_adjust(status, buffer, position.total + 1); if (f_status_is_error(status)) { return status; } // 2: buffer the file - status = f_file_read_at(file, &buffer, length); + status = f_file_read_at(file, &buffer, position); if (f_status_is_error(status)) { return status; diff --git a/level_3/firewall/c/private-firewall.c b/level_3/firewall/c/private-firewall.c index e96939a..3649d41 100644 --- a/level_3/firewall/c/private-firewall.c +++ b/level_3/firewall/c/private-firewall.c @@ -613,9 +613,9 @@ f_return_status firewall_perform_commands(const firewall_local_data local, const f_file_close(&file); } else { - if (file_position.total_elements == 0) { + if (file_position.total == 0) { fseek(file.address, 0, SEEK_END); - file_position.total_elements = ftell(file.address); + file_position.total = ftell(file.address); fseek(file.address, 0, SEEK_SET); } @@ -1478,9 +1478,8 @@ f_return_status firewall_delete_local_data(firewall_local_data *local) { local->is_stop = f_false; local->is_lock = f_false; - local->file_position.buffer_start = 0; - local->file_position.file_start = 0; - local->file_position.total_elements = 0; + local->file_position.start = 0; + local->file_position.total = 0; local->device = 0; local->chain = 0; diff --git a/level_3/fss_basic_list_read/c/fss_basic_list_read.c b/level_3/fss_basic_list_read/c/fss_basic_list_read.c index 93d8366..c1c7ebe 100644 --- a/level_3/fss_basic_list_read/c/fss_basic_list_read.c +++ b/level_3/fss_basic_list_read/c/fss_basic_list_read.c @@ -232,7 +232,7 @@ extern "C" { fss_basic_list_read_depths depths = fss_basic_list_read_depths_initialize; f_string_length counter = 0; - f_string_length original_size = data->file_position.total_elements; + f_string_length original_size = data->file_position.total; status = fss_basic_list_read_main_preprocess_depth(arguments, *data, &depths); if (f_status_is_error(status)) { @@ -301,7 +301,7 @@ extern "C" { status = f_file_open(&file, arguments.argv[data->remaining.array[counter]]); - data->file_position.total_elements = original_size; + data->file_position.total = original_size; if (f_status_is_error(status)) { fss_basic_list_read_print_file_error(data->context, "f_file_open", arguments.argv[data->remaining.array[counter]], f_status_set_fine(status)); @@ -310,13 +310,13 @@ extern "C" { return status; } - if (data->file_position.total_elements == 0) { + if (data->file_position.total == 0) { fseek(file.address, 0, SEEK_END); - data->file_position.total_elements = ftell(file.address); + data->file_position.total = ftell(file.address); // Skip past empty files. - if (data->file_position.total_elements == 0) { + if (data->file_position.total == 0) { f_file_close(&file); continue; } diff --git a/level_3/fss_basic_read/c/fss_basic_read.c b/level_3/fss_basic_read/c/fss_basic_read.c index 8f37d38..dfff8b6 100644 --- a/level_3/fss_basic_read/c/fss_basic_read.c +++ b/level_3/fss_basic_read/c/fss_basic_read.c @@ -232,7 +232,7 @@ extern "C" { fss_basic_read_depths depths = fss_basic_read_depths_initialize; f_string_length counter = 0; - f_string_length original_size = data->file_position.total_elements; + f_string_length original_size = data->file_position.total; status = fss_basic_read_main_preprocess_depth(arguments, *data, &depths); if (f_status_is_error(status)) { @@ -301,7 +301,7 @@ extern "C" { status = f_file_open(&file, arguments.argv[data->remaining.array[counter]]); - data->file_position.total_elements = original_size; + data->file_position.total = original_size; if (f_status_is_error(status)) { fss_basic_read_print_file_error(data->context, "f_file_open", arguments.argv[data->remaining.array[counter]], f_status_set_fine(status)); @@ -311,13 +311,13 @@ extern "C" { return status; } - if (data->file_position.total_elements == 0) { + if (data->file_position.total == 0) { fseek(file.address, 0, SEEK_END); - data->file_position.total_elements = ftell(file.address); + data->file_position.total = ftell(file.address); // Skip past empty files. - if (data->file_position.total_elements == 0) { + if (data->file_position.total == 0) { f_file_close(&file); continue; } diff --git a/level_3/fss_extended_list_read/c/fss_extended_list_read.c b/level_3/fss_extended_list_read/c/fss_extended_list_read.c index b7fc399..c54a1ab 100644 --- a/level_3/fss_extended_list_read/c/fss_extended_list_read.c +++ b/level_3/fss_extended_list_read/c/fss_extended_list_read.c @@ -232,7 +232,7 @@ extern "C" { fss_extended_list_read_depths depths = fss_extended_list_read_depths_initialize; f_string_length counter = 0; - f_string_length original_size = data->file_position.total_elements; + f_string_length original_size = data->file_position.total; status = fss_extended_list_read_main_preprocess_depth(arguments, *data, &depths); if (f_status_is_error(status)) { @@ -285,7 +285,7 @@ extern "C" { status = f_file_open(&file, arguments.argv[data->remaining.array[counter]]); - data->file_position.total_elements = original_size; + data->file_position.total = original_size; if (f_status_is_error(status)) { fss_extended_list_read_print_file_error(data->context, "f_file_open", arguments.argv[data->remaining.array[counter]], f_status_set_fine(status)); @@ -295,13 +295,13 @@ extern "C" { return status; } - if (data->file_position.total_elements == 0) { + if (data->file_position.total == 0) { fseek(file.address, 0, SEEK_END); - data->file_position.total_elements = ftell(file.address); + data->file_position.total = ftell(file.address); // Skip past empty files. - if (data->file_position.total_elements == 0) { + if (data->file_position.total == 0) { f_file_close(&file); continue; } diff --git a/level_3/fss_extended_read/c/fss_extended_read.c b/level_3/fss_extended_read/c/fss_extended_read.c index 2cd3dbb..18abb1e 100644 --- a/level_3/fss_extended_read/c/fss_extended_read.c +++ b/level_3/fss_extended_read/c/fss_extended_read.c @@ -232,7 +232,7 @@ extern "C" { fss_extended_read_depths depths = fss_extended_read_depths_initialize; f_string_length counter = 0; - f_string_length original_size = data->file_position.total_elements; + f_string_length original_size = data->file_position.total; status = fss_extended_read_main_preprocess_depth(arguments, *data, &depths); if (f_status_is_error(status)) { @@ -301,7 +301,7 @@ extern "C" { status = f_file_open(&file, arguments.argv[data->remaining.array[counter]]); - data->file_position.total_elements = original_size; + data->file_position.total = original_size; if (f_status_is_error(status)) { fss_extended_read_print_file_error(data->context, "f_file_open", arguments.argv[data->remaining.array[counter]], f_status_set_fine(status)); @@ -311,13 +311,13 @@ extern "C" { return status; } - if (data->file_position.total_elements == 0) { + if (data->file_position.total == 0) { fseek(file.address, 0, SEEK_END); - data->file_position.total_elements = ftell(file.address); + data->file_position.total = ftell(file.address); // Skip past empty files. - if (data->file_position.total_elements == 0) { + if (data->file_position.total == 0) { f_file_close(&file); continue; }