From dfaa5ecf81f0246e4f40b5044442ee596250ec13 Mon Sep 17 00:00:00 2001 From: Jesse Buhagiar Date: Sun, 12 Jan 2020 18:09:46 +1100 Subject: [PATCH] LibC: Implement append modes for `fopen()` Previously, `fopen()` didn't contain an implementation for the append modes, even though the Kernel supports it via `O_APPEND`. This patch rectifies that by implementing them so an assert is no longer thrown. --- Libraries/LibC/stdio.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Libraries/LibC/stdio.cpp b/Libraries/LibC/stdio.cpp index 0f5e5ee5dc..e57f9b8245 100644 --- a/Libraries/LibC/stdio.cpp +++ b/Libraries/LibC/stdio.cpp @@ -498,6 +498,10 @@ FILE* fopen(const char* pathname, const char* mode) flags = O_WRONLY | O_CREAT | O_TRUNC; else if (!strcmp(mode, "w+") || !strcmp(mode, "wb+")) flags = O_RDWR | O_CREAT | O_TRUNC; + else if (!strcmp(mode, "a") || !strcmp(mode, "ab")) + flags = O_WRONLY | O_APPEND | O_CREAT; + else if (!strcmp(mode, "a+") || !strcmp(mode, "ab+")) + flags = O_RDWR | O_APPEND | O_CREAT; else { fprintf(stderr, "FIXME(LibC): fopen('%s', '%s')\n", pathname, mode); ASSERT_NOT_REACHED();