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.
This commit is contained in:
Jesse Buhagiar 2020-01-12 18:09:46 +11:00 committed by Andreas Kling
parent cdbdd397db
commit dfaa5ecf81
Notes: sideshowbarker 2024-07-19 09:42:28 +09:00

View file

@ -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();