From bab9600be5c7bb67fae6b988fd5fdbae9b710710 Mon Sep 17 00:00:00 2001 From: apio Date: Sun, 19 Mar 2023 19:21:36 +0100 Subject: [PATCH] libc: Add creat() --- libc/include/fcntl.h | 3 +++ libc/src/fcntl.cpp | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/libc/include/fcntl.h b/libc/include/fcntl.h index 5cbfd5d2..0f09a15d 100644 --- a/libc/include/fcntl.h +++ b/libc/include/fcntl.h @@ -13,6 +13,9 @@ extern "C" /* Open a file path and return a file descriptor to it. */ int open(const char* path, int flags, ...); + /* Create a file and return a file descriptor to it. */ + int creat(const char* path, mode_t mode); + #ifdef __cplusplus } #endif diff --git a/libc/src/fcntl.cpp b/libc/src/fcntl.cpp index b9caee0c..e639546f 100644 --- a/libc/src/fcntl.cpp +++ b/libc/src/fcntl.cpp @@ -18,4 +18,9 @@ extern "C" va_end(ap); __errno_return(rc, int); } + + int creat(const char* path, mode_t mode) + { + return open(path, O_WRONLY | O_CREAT | O_TRUNC, mode); + } }