options/ansi: Flush all files on exit and flush all files when fflush(NULL) is called.

Signed-off-by: Dennisbonke <admin@dennisbonke.com>
This commit is contained in:
Dennisbonke 2020-04-20 22:14:05 +02:00
parent 9fcc48e695
commit 7fbc11f4e2
2 changed files with 10 additions and 0 deletions

View file

@ -578,6 +578,15 @@ long ftell(FILE *file_base) {
}
int fflush_unlocked(FILE *file_base) {
if(file_base == NULL) {
// Only flush the files but do not close them.
for(auto it : mlibc::global_file_list) {
if(int e = it->flush(); e)
mlibc::infoLogger() << "mlibc warning: Failed to flush file"
<< frg::endlog;
}
return 0;
}
auto file = static_cast<mlibc::abstract_file *>(file_base);
if(file->flush())
return EOF;

View file

@ -4,6 +4,7 @@
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <stdio.h>
#include <frg/random.hpp>
#include <mlibc/debug.hpp>