From ecb3f882a3d617118b6d72e31fc0db4bb2c39769 Mon Sep 17 00:00:00 2001 From: Mustafa Quraish Date: Mon, 6 Sep 2021 01:03:32 -0400 Subject: [PATCH] LibFileSystemAccessClient: Convert request paths to absolute if needed FileSystemAccessServer requires all paths to be absolute, and will just crash if this is not the case. Instead of expecting the user to always provide an absolute path, the client just checks to see if the path provided was absolute, and if not makes a request with the absolute path instead. --- .../LibFileSystemAccessClient/Client.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibFileSystemAccessClient/Client.cpp b/Userland/Libraries/LibFileSystemAccessClient/Client.cpp index 227fd1e66d..1de1a4e666 100644 --- a/Userland/Libraries/LibFileSystemAccessClient/Client.cpp +++ b/Userland/Libraries/LibFileSystemAccessClient/Client.cpp @@ -8,6 +8,8 @@ // clang-format off #include // clang-format on +#include +#include #include #include @@ -34,7 +36,12 @@ Result Client::request_file_read_only_approved(i32 parent_window_id, String cons GUI::WindowServerConnection::the().async_remove_window_stealing_for_client(child_window_server_client_id, parent_window_id); }); - async_request_file_read_only_approved(parent_window_server_client_id, parent_window_id, path); + if (path.starts_with('/')) { + async_request_file_read_only_approved(parent_window_server_client_id, parent_window_id, path); + } else { + auto full_path = LexicalPath::join(Core::File::current_working_directory(), path).string(); + async_request_file_read_only_approved(parent_window_server_client_id, parent_window_id, full_path); + } return m_promise->await(); } @@ -51,7 +58,12 @@ Result Client::request_file(i32 parent_window_id, String const& path, Core::Open GUI::WindowServerConnection::the().async_remove_window_stealing_for_client(child_window_server_client_id, parent_window_id); }); - async_request_file(parent_window_server_client_id, parent_window_id, path, mode); + if (path.starts_with('/')) { + async_request_file(parent_window_server_client_id, parent_window_id, path, mode); + } else { + auto full_path = LexicalPath::join(Core::File::current_working_directory(), path).string(); + async_request_file(parent_window_server_client_id, parent_window_id, full_path, mode); + } return m_promise->await(); }