| ... | ... |
@@ -109,17 +109,17 @@ file_read(void *dest, Uint16 len) |
| 109 | 109 |
Uint16 |
| 110 | 110 |
file_write(void *src, Uint16 len, Uint8 flags) |
| 111 | 111 |
{
|
| 112 |
+ Uint16 ret = 0; |
|
| 112 | 113 |
if(state != FILE_WRITE) {
|
| 113 | 114 |
reset(); |
| 114 | 115 |
if((f = fopen(current_filename, (flags & 0x01) ? "ab" : "wb")) != NULL) |
| 115 | 116 |
state = FILE_WRITE; |
| 116 | 117 |
} |
| 117 | 118 |
if(state == FILE_WRITE) {
|
| 118 |
- Uint16 ret = fwrite(src, 1, len, f); |
|
| 119 |
- fflush(f); |
|
| 120 |
- return ret; |
|
| 119 |
+ if((ret = fwrite(src, 1, len, f)) > 0 && fflush(f) != 0) |
|
| 120 |
+ ret = 0; |
|
| 121 | 121 |
} |
| 122 |
- return 0; |
|
| 122 |
+ return ret; |
|
| 123 | 123 |
} |
| 124 | 124 |
|
| 125 | 125 |
Uint16 |