diff --git a/Userland/Libraries/LibCore/System.cpp b/Userland/Libraries/LibCore/System.cpp index 9d7844d6cf..70f3a01cfa 100644 --- a/Userland/Libraries/LibCore/System.cpp +++ b/Userland/Libraries/LibCore/System.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -997,6 +998,16 @@ ErrorOr mkstemp(Span pattern) return fd; } +ErrorOr mkdtemp(Span pattern) +{ + auto* path = ::mkdtemp(pattern.data()); + if (path == nullptr) { + return Error::from_errno(errno); + } + + return String::from_utf8({ path, strlen(path) }); +} + ErrorOr rename(StringView old_path, StringView new_path) { if (old_path.is_null() || new_path.is_null()) diff --git a/Userland/Libraries/LibCore/System.h b/Userland/Libraries/LibCore/System.h index d3cc68baf3..2c0f73b1e9 100644 --- a/Userland/Libraries/LibCore/System.h +++ b/Userland/Libraries/LibCore/System.h @@ -166,6 +166,7 @@ ErrorOr chdir(StringView path); ErrorOr rmdir(StringView path); ErrorOr fork(); ErrorOr mkstemp(Span pattern); +ErrorOr mkdtemp(Span pattern); ErrorOr fchmod(int fd, mode_t mode); ErrorOr fchown(int fd, uid_t, gid_t); ErrorOr rename(StringView old_path, StringView new_path);