mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 17:17:44 +00:00
LibCore: Add a Core::System wrapper around unsetenv
This commit is contained in:
parent
2437064820
commit
6655de189f
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue