diff --git a/Ladybird/HelperProcess.cpp b/Ladybird/HelperProcess.cpp index 0f79a06f703..198e1484c16 100644 --- a/Ladybird/HelperProcess.cpp +++ b/Ladybird/HelperProcess.cpp @@ -8,7 +8,7 @@ ErrorOr> launch_web_content_process( WebView::ViewImplementation& view, - ReadonlySpan candidate_web_content_paths, + ReadonlySpan candidate_web_content_paths, Ladybird::WebContentOptions const& web_content_options) { int socket_fds[2] {}; @@ -43,7 +43,7 @@ ErrorOr> launch_web_content_process( "valgrind"sv, "--tool=callgrind"sv, "--instr-atstart=no"sv, - path.bytes_as_string_view(), + path.view(), "--command-line"sv, web_content_options.command_line, "--executable-path"sv, @@ -97,7 +97,7 @@ ErrorOr> launch_web_content_process( } template -ErrorOr> launch_generic_server_process(ReadonlySpan candidate_server_paths, StringView serenity_resource_root, Vector const& certificates, StringView server_name) +ErrorOr> launch_generic_server_process(ReadonlySpan candidate_server_paths, StringView serenity_resource_root, Vector const& certificates, StringView server_name) { int socket_fds[2] {}; TRY(Core::System::socketpair(AF_LOCAL, SOCK_STREAM, 0, socket_fds)); @@ -127,7 +127,7 @@ ErrorOr> launch_generic_server_process(ReadonlySpan { - path.bytes_as_string_view(), + path.view(), "--fd-passing-socket"sv, fd_passing_socket_string, }; @@ -163,22 +163,22 @@ ErrorOr> launch_generic_server_process(ReadonlySpan> launch_image_decoder_process(ReadonlySpan candidate_image_decoder_paths) +ErrorOr> launch_image_decoder_process(ReadonlySpan candidate_image_decoder_paths) { return launch_generic_server_process(candidate_image_decoder_paths, ""sv, {}, "ImageDecoder"sv); } -ErrorOr> launch_web_worker_process(ReadonlySpan candidate_web_worker_paths, Vector const& certificates) +ErrorOr> launch_web_worker_process(ReadonlySpan candidate_web_worker_paths, Vector const& certificates) { return launch_generic_server_process(candidate_web_worker_paths, ""sv, certificates, "WebWorker"sv); } -ErrorOr> launch_request_server_process(ReadonlySpan candidate_request_server_paths, StringView serenity_resource_root, Vector const& certificates) +ErrorOr> launch_request_server_process(ReadonlySpan candidate_request_server_paths, StringView serenity_resource_root, Vector const& certificates) { return launch_generic_server_process(candidate_request_server_paths, serenity_resource_root, certificates, "RequestServer"sv); } -ErrorOr> launch_web_socket_process(ReadonlySpan candidate_web_socket_paths, StringView serenity_resource_root, Vector const& certificates) +ErrorOr> launch_web_socket_process(ReadonlySpan candidate_web_socket_paths, StringView serenity_resource_root, Vector const& certificates) { return launch_generic_server_process(candidate_web_socket_paths, serenity_resource_root, certificates, "WebSocket"sv); } diff --git a/Ladybird/HelperProcess.h b/Ladybird/HelperProcess.h index ca7c61f3069..90605c77eae 100644 --- a/Ladybird/HelperProcess.h +++ b/Ladybird/HelperProcess.h @@ -19,10 +19,10 @@ ErrorOr> launch_web_content_process( WebView::ViewImplementation& view, - ReadonlySpan candidate_web_content_paths, + ReadonlySpan candidate_web_content_paths, Ladybird::WebContentOptions const&); -ErrorOr> launch_image_decoder_process(ReadonlySpan candidate_image_decoder_paths); -ErrorOr> launch_web_worker_process(ReadonlySpan candidate_web_worker_paths, Vector const& certificates); -ErrorOr> launch_request_server_process(ReadonlySpan candidate_request_server_paths, StringView serenity_resource_root, Vector const& certificates); -ErrorOr> launch_web_socket_process(ReadonlySpan candidate_web_socket_paths, StringView serenity_resource_root, Vector const& certificates); +ErrorOr> launch_image_decoder_process(ReadonlySpan candidate_image_decoder_paths); +ErrorOr> launch_web_worker_process(ReadonlySpan candidate_web_worker_paths, Vector const& certificates); +ErrorOr> launch_request_server_process(ReadonlySpan candidate_request_server_paths, StringView serenity_resource_root, Vector const& certificates); +ErrorOr> launch_web_socket_process(ReadonlySpan candidate_web_socket_paths, StringView serenity_resource_root, Vector const& certificates); diff --git a/Ladybird/Utilities.cpp b/Ladybird/Utilities.cpp index 0e2e0be0766..dc0423c7981 100644 --- a/Ladybird/Utilities.cpp +++ b/Ladybird/Utilities.cpp @@ -14,11 +14,10 @@ ByteString s_serenity_resource_root; -ErrorOr application_directory() +ErrorOr application_directory() { auto current_executable_path = TRY(Core::System::current_executable_path()); - auto dirname = LexicalPath::dirname(current_executable_path); - return String::from_byte_string(dirname); + return LexicalPath::dirname(current_executable_path); } void platform_init() @@ -33,7 +32,7 @@ void platform_init() auto home_lagom = ByteString::formatted("{}/.lagom", home); if (FileSystem::is_directory(home_lagom)) return home_lagom; - auto app_dir = application_directory().release_value_but_fixme_should_propagate_errors().to_byte_string(); + auto app_dir = MUST(application_directory()); #ifdef AK_OS_MACOS return LexicalPath(app_dir).parent().append("Resources"sv).string(); #else @@ -44,13 +43,13 @@ void platform_init() Core::ResourceImplementation::install(make(MUST(String::formatted("{}/res", s_serenity_resource_root)))); } -ErrorOr> get_paths_for_helper_process(StringView process_name) +ErrorOr> get_paths_for_helper_process(StringView process_name) { auto application_path = TRY(application_directory()); - Vector paths; + Vector paths; - TRY(paths.try_append(TRY(String::formatted("{}/{}", application_path, process_name)))); - TRY(paths.try_append(TRY(String::formatted("./{}", process_name)))); + TRY(paths.try_append(ByteString::formatted("{}/{}", application_path, process_name))); + TRY(paths.try_append(ByteString::formatted("./{}", process_name))); // NOTE: Add platform-specific paths here return paths; } diff --git a/Ladybird/Utilities.h b/Ladybird/Utilities.h index f754fbee5a0..a033f7e8d2e 100644 --- a/Ladybird/Utilities.h +++ b/Ladybird/Utilities.h @@ -13,7 +13,7 @@ #include void platform_init(); -ErrorOr application_directory(); -ErrorOr> get_paths_for_helper_process(StringView process_name); +ErrorOr application_directory(); +ErrorOr> get_paths_for_helper_process(StringView process_name); extern ByteString s_serenity_resource_root; diff --git a/Ladybird/WebDriver/main.cpp b/Ladybird/WebDriver/main.cpp index 8e678357ed3..9d6f2e64005 100644 --- a/Ladybird/WebDriver/main.cpp +++ b/Ladybird/WebDriver/main.cpp @@ -24,7 +24,7 @@ static ErrorOr launch_process(StringView application, ReadonlySpan result = -1; for (auto const& path : paths) { - auto path_view = path.bytes_as_string_view(); + auto path_view = path.view(); result = Core::Process::spawn(path_view, arguments, {}, Core::Process::KeepAsChild::Yes); if (!result.is_error()) break; diff --git a/Userland/Libraries/LibSQL/SQLClient.cpp b/Userland/Libraries/LibSQL/SQLClient.cpp index 93d4037dfe2..0b6e4876877 100644 --- a/Userland/Libraries/LibSQL/SQLClient.cpp +++ b/Userland/Libraries/LibSQL/SQLClient.cpp @@ -52,7 +52,7 @@ static ErrorOr create_database_socket(ByteString const& socket_path) return socket_fd; } -static ErrorOr launch_server(ByteString const& socket_path, ByteString const& pid_path, Vector candidate_server_paths) +static ErrorOr launch_server(ByteString const& socket_path, ByteString const& pid_path, Vector candidate_server_paths) { auto server_fd_or_error = create_database_socket(socket_path); if (server_fd_or_error.is_error()) { @@ -87,7 +87,7 @@ static ErrorOr launch_server(ByteString const& socket_path, ByteString con ErrorOr result; for (auto const& server_path : candidate_server_paths) { auto arguments = Array { - server_path.bytes_as_string_view(), + server_path.view(), "--pid-file"sv, pid_path, }; @@ -147,7 +147,7 @@ static ErrorOr should_launch_server(ByteString const& pid_path) return false; } -ErrorOr> SQLClient::launch_server_and_create_client(Vector candidate_server_paths) +ErrorOr> SQLClient::launch_server_and_create_client(Vector candidate_server_paths) { auto runtime_directory = TRY(Core::StandardPaths::runtime_directory()); auto socket_path = ByteString::formatted("{}/SQLServer.socket", runtime_directory); diff --git a/Userland/Libraries/LibSQL/SQLClient.h b/Userland/Libraries/LibSQL/SQLClient.h index ef3b2ca570c..02cd3d76e0c 100644 --- a/Userland/Libraries/LibSQL/SQLClient.h +++ b/Userland/Libraries/LibSQL/SQLClient.h @@ -55,7 +55,7 @@ class SQLClient public: #if !defined(AK_OS_SERENITY) - static ErrorOr> launch_server_and_create_client(Vector candidate_server_paths); + static ErrorOr> launch_server_and_create_client(Vector candidate_server_paths); #endif virtual ~SQLClient() = default; diff --git a/Userland/Libraries/LibWebView/Database.cpp b/Userland/Libraries/LibWebView/Database.cpp index c0afb48d709..3e2f3cf0f7b 100644 --- a/Userland/Libraries/LibWebView/Database.cpp +++ b/Userland/Libraries/LibWebView/Database.cpp @@ -19,7 +19,7 @@ ErrorOr> Database::create() #if !defined(AK_OS_SERENITY) -ErrorOr> Database::create(Vector candidate_sql_server_paths) +ErrorOr> Database::create(Vector candidate_sql_server_paths) { auto sql_client = TRY(SQL::SQLClient::launch_server_and_create_client(move(candidate_sql_server_paths))); return create(move(sql_client)); diff --git a/Userland/Libraries/LibWebView/Database.h b/Userland/Libraries/LibWebView/Database.h index 3963098f975..bc7ed7d79cb 100644 --- a/Userland/Libraries/LibWebView/Database.h +++ b/Userland/Libraries/LibWebView/Database.h @@ -30,7 +30,7 @@ class Database : public RefCounted { public: static ErrorOr> create(); #if !defined(AK_OS_SERENITY) - static ErrorOr> create(Vector candidate_sql_server_paths); + static ErrorOr> create(Vector candidate_sql_server_paths); #endif ErrorOr prepare_statement(StringView statement); diff --git a/Userland/Utilities/sql.cpp b/Userland/Utilities/sql.cpp index d98269df1c2..431cc3c75ba 100644 --- a/Userland/Utilities/sql.cpp +++ b/Userland/Utilities/sql.cpp @@ -360,7 +360,7 @@ ErrorOr serenity_main(Main::Arguments arguments) auto sql_client = TRY(SQL::SQLClient::try_create()); #else VERIFY(!sql_server_path.is_empty()); - auto sql_client = TRY(SQL::SQLClient::launch_server_and_create_client({ TRY(String::from_utf8(sql_server_path)) })); + auto sql_client = TRY(SQL::SQLClient::launch_server_and_create_client({ sql_server_path })); #endif SQLRepl repl(loop, database_name, move(sql_client));