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); + } }