diff options
author | Jesse Buhagiar <jesse.buhagiar@student.rmit.edu.au> | 2020-01-12 18:09:46 +1100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-02-02 10:58:45 +0100 |
commit | dfaa5ecf81f0246e4f40b5044442ee596250ec13 (patch) | |
tree | eaf84ab2cd7be2e58a2d26fdd0ea7e7cca8477fe /Libraries/LibC/stdio.cpp | |
parent | cdbdd397db2dbab2a01115ab847ae658237feb3b (diff) | |
download | serenity-dfaa5ecf81f0246e4f40b5044442ee596250ec13.zip |
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.
Diffstat (limited to 'Libraries/LibC/stdio.cpp')
-rw-r--r-- | Libraries/LibC/stdio.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
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(); |