From aa7e8b5797d498208edd73d1fb2533bc29d5c2fe Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Thu, 16 Dec 2021 21:10:59 +0100 Subject: [PATCH] LibCore: Add syscall wrapper for mkstemp() --- Userland/Libraries/LibCore/System.cpp | 8 ++++++++ Userland/Libraries/LibCore/System.h | 1 + 2 files changed, 9 insertions(+) diff --git a/Userland/Libraries/LibCore/System.cpp b/Userland/Libraries/LibCore/System.cpp index d4807c8b17..43f23a4e5d 100644 --- a/Userland/Libraries/LibCore/System.cpp +++ b/Userland/Libraries/LibCore/System.cpp @@ -488,4 +488,12 @@ ErrorOr fork() return pid; } +ErrorOr mkstemp(Span pattern) +{ + int fd = ::mkstemp(pattern.data()); + if (fd < 0) + return Error::from_syscall("mkstemp"sv, -errno); + return fd; +} + } diff --git a/Userland/Libraries/LibCore/System.h b/Userland/Libraries/LibCore/System.h index c4b668739a..e9ce8f1d7f 100644 --- a/Userland/Libraries/LibCore/System.h +++ b/Userland/Libraries/LibCore/System.h @@ -65,5 +65,6 @@ ErrorOr isatty(int fd); ErrorOr symlink(StringView target, StringView link_path); ErrorOr mkdir(StringView path, mode_t); ErrorOr fork(); +ErrorOr mkstemp(Span pattern); }