From 934c30d35a3ca0e0bf6cd8709d779e060e27f6d2 Mon Sep 17 00:00:00 2001 From: Anton Kling Date: Sat, 23 Nov 2024 14:59:26 +0100 Subject: libc: Add append to f(d)open and other fixes --- userland/libc/stdio/fwrite.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'userland/libc/stdio/fwrite.c') 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 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); -- cgit v1.2.3