Created
November 6, 2021 19:18
-
-
Save DeltaF1/712cd4fb32bb6d71218b28d87b9960b2 to your computer and use it in GitHub Desktop.
Patch to fix incomplete file writing in uxn file device
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Uint16 | |
file_write(void *src, Uint16 len, Uint8 flags) | |
{ | |
+ /* If we're not already writing then re-open the file */ | |
if(state != FILE_WRITE) { | |
reset(); | |
if((f = fopen(current_filename, (flags & 0x01) ? "ab" : "wb")) != NULL) | |
state = FILE_WRITE; | |
} | |
- if(state == FILE_WRITE) | |
- return fwrite(src, 1, len, f); | |
+ | |
+ size_t bytes_written; | |
+ if(state == FILE_WRITE) { | |
+ bytes_written = fwrite(src, 1, len, f); | |
+ fflush(f); | |
+ return bytes_written; | |
+ } | |
+ | |
return 0; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment