diff options
author | Anton Kling <anton@kling.gg> | 2024-11-23 14:59:26 +0100 |
---|---|---|
committer | Anton Kling <anton@kling.gg> | 2024-11-23 16:31:25 +0100 |
commit | 934c30d35a3ca0e0bf6cd8709d779e060e27f6d2 (patch) | |
tree | b2d5df8919b7bf721b9901b56cccad3f3d1644e0 /userland/libc/stdio/fwrite.c | |
parent | 2dce92236b9fe0a9398287ac7c62f2f4e67d53b6 (diff) |
libc: Add append to f(d)open and other fixes
Diffstat (limited to 'userland/libc/stdio/fwrite.c')
-rw-r--r-- | userland/libc/stdio/fwrite.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/userland/libc/stdio/fwrite.c b/userland/libc/stdio/fwrite.c index 6499529..d2086cb 100644 --- a/userland/libc/stdio/fwrite.c +++ b/userland/libc/stdio/fwrite.c @@ -2,6 +2,11 @@ #include <sys/types.h> size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream) { + if (!stream->has_control_over_the_fd) { + if (stream->append) { + fseek(stream, 0, SEEK_END); + } + } // FIXME: Check for overflow size_t bytes_to_write = nmemb * size; size_t rc = stream->write(stream, ptr, bytes_to_write); |