mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-12 10:40:39 +09:00
LibCore: Add syscall wrapper for mkdtemp()
This commit is contained in:
parent
1f99f9523d
commit
5072a2280d
Notes:
sideshowbarker
2024-07-17 01:27:18 +09:00
Author: https://github.com/caoimhebyrne 🔰
Commit: 5072a2280d
Pull-request: https://github.com/SerenityOS/serenity/pull/17905
Reviewed-by: https://github.com/linusg ✅
2 changed files with 12 additions and 0 deletions
|
@ -11,6 +11,7 @@
|
||||||
#include <AK/FixedArray.h>
|
#include <AK/FixedArray.h>
|
||||||
#include <AK/ScopedValueRollback.h>
|
#include <AK/ScopedValueRollback.h>
|
||||||
#include <AK/StdLibExtras.h>
|
#include <AK/StdLibExtras.h>
|
||||||
|
#include <AK/String.h>
|
||||||
#include <AK/Vector.h>
|
#include <AK/Vector.h>
|
||||||
#include <LibCore/DeprecatedFile.h>
|
#include <LibCore/DeprecatedFile.h>
|
||||||
#include <LibCore/SessionManagement.h>
|
#include <LibCore/SessionManagement.h>
|
||||||
|
@ -997,6 +998,16 @@ ErrorOr<int> mkstemp(Span<char> pattern)
|
||||||
return fd;
|
return fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ErrorOr<String> mkdtemp(Span<char> pattern)
|
||||||
|
{
|
||||||
|
auto* path = ::mkdtemp(pattern.data());
|
||||||
|
if (path == nullptr) {
|
||||||
|
return Error::from_errno(errno);
|
||||||
|
}
|
||||||
|
|
||||||
|
return String::from_utf8({ path, strlen(path) });
|
||||||
|
}
|
||||||
|
|
||||||
ErrorOr<void> rename(StringView old_path, StringView new_path)
|
ErrorOr<void> rename(StringView old_path, StringView new_path)
|
||||||
{
|
{
|
||||||
if (old_path.is_null() || new_path.is_null())
|
if (old_path.is_null() || new_path.is_null())
|
||||||
|
|
|
@ -166,6 +166,7 @@ ErrorOr<void> chdir(StringView path);
|
||||||
ErrorOr<void> rmdir(StringView path);
|
ErrorOr<void> rmdir(StringView path);
|
||||||
ErrorOr<pid_t> fork();
|
ErrorOr<pid_t> fork();
|
||||||
ErrorOr<int> mkstemp(Span<char> pattern);
|
ErrorOr<int> mkstemp(Span<char> pattern);
|
||||||
|
ErrorOr<String> mkdtemp(Span<char> pattern);
|
||||||
ErrorOr<void> fchmod(int fd, mode_t mode);
|
ErrorOr<void> fchmod(int fd, mode_t mode);
|
||||||
ErrorOr<void> fchown(int fd, uid_t, gid_t);
|
ErrorOr<void> fchown(int fd, uid_t, gid_t);
|
||||||
ErrorOr<void> rename(StringView old_path, StringView new_path);
|
ErrorOr<void> rename(StringView old_path, StringView new_path);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue