mirror of
https://git.sr.ht/~rabbits/uxn
synced 2024-11-27 08:13:01 +00:00
file: write: return error if fflush failed
This commit is contained in:
parent
054361cb70
commit
fd7cf5e221
1 changed files with 4 additions and 4 deletions
|
@ -109,17 +109,17 @@ file_read(void *dest, Uint16 len)
|
||||||
Uint16
|
Uint16
|
||||||
file_write(void *src, Uint16 len, Uint8 flags)
|
file_write(void *src, Uint16 len, Uint8 flags)
|
||||||
{
|
{
|
||||||
|
Uint16 ret = 0;
|
||||||
if(state != FILE_WRITE) {
|
if(state != FILE_WRITE) {
|
||||||
reset();
|
reset();
|
||||||
if((f = fopen(current_filename, (flags & 0x01) ? "ab" : "wb")) != NULL)
|
if((f = fopen(current_filename, (flags & 0x01) ? "ab" : "wb")) != NULL)
|
||||||
state = FILE_WRITE;
|
state = FILE_WRITE;
|
||||||
}
|
}
|
||||||
if(state == FILE_WRITE) {
|
if(state == FILE_WRITE) {
|
||||||
Uint16 ret = fwrite(src, 1, len, f);
|
if((ret = fwrite(src, 1, len, f)) > 0 && fflush(f) != 0)
|
||||||
fflush(f);
|
ret = 0;
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
return 0;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
Uint16
|
Uint16
|
||||||
|
|
Loading…
Reference in a new issue