return file.stream ? F_data_not : F_stream_not;
}
- f_status_t status = F_okay;
-
if (written) {
- status = private_f_file_stream_write_until(file, buffer, buffer.used, written);
-
- if (status == F_okay && *written == buffer.used) return F_okay_eos;
- }
- else {
- f_number_unsigned_t written_local = 0;
-
- status = private_f_file_stream_write_until(file, buffer, buffer.used, &written_local);
-
- if (status == F_okay && written_local == buffer.used) return F_okay_eos;
+ return private_f_file_stream_write_until(file, buffer, buffer.used, written);
}
- if (F_status_is_error(status)) return status;
+ f_number_unsigned_t written_local = 0;
- return F_okay;
+ return private_f_file_stream_write_until(file, buffer, buffer.used, &written_local);
}
#endif // _di_f_file_stream_write_
return file.stream ? F_data_not : F_stream_not;
}
- const f_number_unsigned_t write_max = file.size_write > buffer.used ? buffer.used : file.size_write;
-
- f_status_t status = F_okay;
-
if (written) {
- status = private_f_file_stream_write_until(file, buffer, write_max, written);
-
- if (status == F_okay) {
- if (*written == buffer.used) return F_okay_eos;
- if (*written == write_max) return F_okay_stop;
- }
- }
- else {
- f_number_unsigned_t written_local = 0;
-
- status = private_f_file_stream_write_until(file, buffer, write_max, &written_local);
-
- if (status == F_okay) {
- if (written_local == buffer.used) return F_okay_eos;
- if (written_local == write_max) return F_okay_stop;
- }
+ return private_f_file_stream_write_until(file, buffer, file.size_write > buffer.used ? buffer.used : file.size_write, written);
}
- if (F_status_is_error(status)) return status;
+ f_number_unsigned_t written_local = 0;
- return F_okay;
+ return private_f_file_stream_write_until(file, buffer, file.size_write > buffer.used ? buffer.used : file.size_write, &written_local);
}
#endif // _di_f_file_stream_write_block_
return file.stream ? F_data_not : F_stream_not;
}
- const f_number_unsigned_t write_max = total > buffer.used ? buffer.used : total;
-
- f_status_t status = F_okay;
-
if (written) {
- status = private_f_file_stream_write_until(file, buffer, write_max, written);
-
- if (status == F_okay) {
- if (*written == buffer.used) return F_okay_eos;
- if (*written == write_max) return F_okay_stop;
- }
- }
- else {
- f_number_unsigned_t written_local = 0;
-
- status = private_f_file_stream_write_until(file, buffer, buffer.used, &written_local);
-
- if (status == F_okay) {
- if (written_local == buffer.used) return F_okay_eos;
- if (written_local == write_max) return F_okay_stop;
- }
+ return private_f_file_stream_write_until(file, buffer, total > buffer.used ? buffer.used : total, written);
}
- if (F_status_is_error(status)) return status;
+ f_number_unsigned_t written_local = 0;
- return F_okay;
+ return private_f_file_stream_write_until(file, buffer, total > buffer.used ? buffer.used : total, &written_local);
}
#endif // _di_f_file_stream_write_until_
return file.stream ? F_data_not : F_stream_not;
}
- const f_number_unsigned_t write_max = (range.stop - range.start) + 1 > buffer.used ? buffer.used : (range.stop - range.start) + 1;
- const f_string_static_t buffer_adjusted = macro_f_string_static_t_initialize_3(buffer.string + range.start, buffer.used - range.start);
-
- f_status_t status = F_okay;
+ const f_string_static_t adjusted = macro_f_string_static_t_initialize_3(buffer.string + range.start, buffer.used - range.start);
if (written) {
- status = private_f_file_stream_write_until(file, buffer_adjusted, write_max, written);
-
- if (status == F_okay) {
- if (range.start + *written == buffer.used) return F_okay_eos;
- if (range.start + *written == write_max) return F_okay_stop;
- }
- }
- else {
- f_number_unsigned_t written_local = 0;
-
- status = private_f_file_stream_write_until(file, buffer_adjusted, write_max, &written_local);
-
- if (status == F_okay) {
- if (range.start + written_local == buffer.used) return F_okay_eos;
- if (range.start + written_local == write_max) return F_okay_stop;
- }
+ return private_f_file_stream_write_until(file, adjusted, (range.stop - range.start) + 1 > buffer.used ? buffer.used : (range.stop - range.start) + 1, written);
}
- if (F_status_is_error(status)) return status;
+ f_number_unsigned_t written_local = 0;
- return F_okay;
+ return private_f_file_stream_write_until(file, adjusted, (range.stop - range.start) + 1 > buffer.used ? buffer.used : (range.stop - range.start) + 1, &written_local);
}
#endif // _di_f_file_stream_write_range_
*
* @return
* F_okay on success.
- * F_okay_eof when the file stream is at the end of the file.
* F_okay_stop on success but no data was written (written == 0) (not an error and often happens if file type is not a regular file).
* F_data_not on success but buffer.used is 0.
* F_stream_not if file.stream is NULL.
*
* F_file_write (with error bit) on any other error.
*
- * @see ferror_unlocked()
* @see flockfile()
* @see fwrite_unlocked()
+ * @see ferror_unlocked()
* @see funlockfile()
*/
#ifndef _di_f_file_stream_write_
*
* @return
* F_okay on success.
- * F_okay_eof when the file stream is at the end of the file.
- * F_okay_stop on success but no data was written (written == 0) (not an error and often happens if file type is not a regular file).
- * F_data_not on success but buffer.used is 0.
+ * F_okay_eos on success after reaching the end of the buffer (only wrote up to buffer.used).
+ * F_okay_stop on success after reaching stopping point (only wrote up to the lesser of total and buffer.used).
+ * F_data_not on success but either buffer.used or total is 0.
* F_stream_not if file.stream is NULL.
*
* F_file_write (with error bit) on error during file write.
* F_parameter (with error bit) if a parameter is invalid.
*
- * F_file_write (with error bit) on any other error.
- *
- * @see flockfile()
- * @see fwrite_unlocked()
* @see ferror_unlocked()
+ * @see flockfile()
* @see funlockfile()
+ * @see fwrite_unlocked()
*/
#ifndef _di_f_file_stream_write_block_
extern f_status_t f_file_stream_write_block(const f_file_t file, const f_string_static_t buffer, f_number_unsigned_t * const written);
*
* @return
* F_okay on success.
- * F_okay_eof when the file stream is at the end of the file.
- * F_okay_eos on success but range.stop exceeded buffer.used (only wrote up to buffer.used).
- * F_okay_stop on success but no data was written (written == 0) (not an error and often happens if file type is not a regular file).
+ * F_okay_eos on success after reaching the end of the buffer (only wrote up to buffer.used).
+ * F_okay_stop on success after reaching stopping point (only wrote up to the lesser of total and buffer.used).
* F_data_not on success but either buffer.used or total is 0.
* F_stream_not if file.stream is NULL.
*
* F_file_write (with error bit) on error during file write.
* F_parameter (with error bit) if a parameter is invalid.
*
- * F_file_write (with error bit) on any other error.
- *
- * @see flockfile()
- * @see fwrite_unlocked()
* @see ferror_unlocked()
+ * @see flockfile()
* @see funlockfile()
+ * @see fwrite_unlocked()
*/
#ifndef _di_f_file_stream_write_until_
extern f_status_t f_file_stream_write_until(const f_file_t file, const f_string_static_t buffer, const f_number_unsigned_t total, f_number_unsigned_t * const written);
*
* @return
* F_okay on success.
- * F_okay_stop on success but no data was written (written == 0) (not an error and often happens if file type is not a regular file).
- * F_okay_eos on success but range.stop exceeded buffer.used (only wrote up to buffer.used).
+ * F_okay_eos on success after reaching the end of the buffer (only wrote up to buffer.used).
+ * F_okay_stop on success after reaching stopping point (only wrote up to the lesser of total and buffer.used).
+ * F_data_not on success but either buffer.used or total is 0.
* F_stream_not if file.stream is NULL.
*
* F_file_write (with error bit) on error during file write.
* F_parameter (with error bit) if a parameter is invalid.
*
+ * @see ferror_unlocked()
+ * @see flockfile()
+ * @see funlockfile()
* @see fwrite_unlocked()
*/
#ifndef _di_f_file_stream_write_range_