Ladybird: Use Core::Environment instead of Core::System::*env()

This commit is contained in:
Sam Atkins 2024-01-30 16:16:17 +00:00 committed by Sam Atkins
parent c6b9ce22ef
commit 163a40c539
2 changed files with 7 additions and 4 deletions

View file

@ -5,6 +5,7 @@
*/
#include "HelperProcess.h"
#include <LibCore/Environment.h>
ErrorOr<NonnullRefPtr<WebView::WebContentClient>> launch_web_content_process(
WebView::ViewImplementation& view,
@ -28,7 +29,7 @@ ErrorOr<NonnullRefPtr<WebView::WebContentClient>> launch_web_content_process(
TRY(Core::System::close(ui_fd));
auto takeover_string = TRY(String::formatted("WebContent:{}", wc_fd));
TRY(Core::System::setenv("SOCKET_TAKEOVER"sv, takeover_string, true));
TRY(Core::Environment::set("SOCKET_TAKEOVER"sv, takeover_string, Core::Environment::Overwrite::Yes));
auto webcontent_fd_passing_socket_string = TRY(String::number(wc_fd_passing_fd));
@ -116,7 +117,7 @@ ErrorOr<NonnullRefPtr<Client>> launch_generic_server_process(ReadonlySpan<ByteSt
TRY(Core::System::close(ui_fd_passing_fd));
auto takeover_string = TRY(String::formatted("{}:{}", server_name, server_fd));
TRY(Core::System::setenv("SOCKET_TAKEOVER"sv, takeover_string, true));
TRY(Core::Environment::set("SOCKET_TAKEOVER"sv, takeover_string, Core::Environment::Overwrite::Yes));
auto fd_passing_socket_string = TRY(String::number(server_fd_passing_fd));

View file

@ -8,6 +8,7 @@
#include "Utilities.h"
#include <AK/LexicalPath.h>
#include <AK/Platform.h>
#include <LibCore/Environment.h>
#include <LibCore/ResourceImplementationFile.h>
#include <LibCore/System.h>
#include <LibFileSystem/FileSystem.h>
@ -45,8 +46,9 @@ static LexicalPath find_prefix(LexicalPath const& application_directory)
void platform_init()
{
s_serenity_resource_root = [] {
auto* home = getenv("XDG_CONFIG_HOME") ?: getenv("HOME");
if (home != nullptr) {
auto home = Core::Environment::get("XDG_CONFIG_HOME"sv)
.value_or_lazy_evaluated_optional([]() { return Core::Environment::get("HOME"sv); });
if (home.has_value()) {
auto home_lagom = ByteString::formatted("{}/.lagom", home);
if (FileSystem::is_directory(home_lagom))
return home_lagom;