Explorar el Código

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.
Jesse Buhagiar hace 5 años
padre
commit
dfaa5ecf81
Se han modificado 1 ficheros con 4 adiciones y 0 borrados
  1. 4 0
      Libraries/LibC/stdio.cpp

+ 4 - 0
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();