LibCore: Add a Core::System wrapper around unsetenv
This commit is contained in:
parent
2437064820
commit
6655de189f
Notes:
sideshowbarker
2024-07-16 22:51:10 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/6655de189f Pull-request: https://github.com/SerenityOS/serenity/pull/21833
2 changed files with 14 additions and 0 deletions
|
@ -1639,6 +1639,19 @@ ErrorOr<void> setenv(StringView name, StringView value, bool overwrite)
|
|||
return {};
|
||||
}
|
||||
|
||||
ErrorOr<void> unsetenv(StringView name)
|
||||
{
|
||||
auto builder = TRY(StringBuilder::create());
|
||||
TRY(builder.try_append(name));
|
||||
TRY(builder.try_append('\0'));
|
||||
|
||||
// Note the explicit null terminator above.
|
||||
auto rc = ::unsetenv(builder.string_view().characters_without_null_termination());
|
||||
if (rc < 0)
|
||||
return Error::from_errno(errno);
|
||||
return {};
|
||||
}
|
||||
|
||||
ErrorOr<void> putenv(StringView env)
|
||||
{
|
||||
#ifdef AK_OS_SERENITY
|
||||
|
|
|
@ -229,6 +229,7 @@ ErrorOr<void> setgroups(ReadonlySpan<gid_t>);
|
|||
ErrorOr<void> mknod(StringView pathname, mode_t mode, dev_t dev);
|
||||
ErrorOr<void> mkfifo(StringView pathname, mode_t mode);
|
||||
ErrorOr<void> setenv(StringView, StringView, bool);
|
||||
ErrorOr<void> unsetenv(StringView);
|
||||
ErrorOr<void> putenv(StringView);
|
||||
ErrorOr<int> posix_openpt(int flags);
|
||||
ErrorOr<void> grantpt(int fildes);
|
||||
|
|
Loading…
Add table
Reference in a new issue