diff options
author | Mustafa Quraish <mustafaq9@gmail.com> | 2021-09-06 01:03:32 -0400 |
---|---|---|
committer | Ali Mohammad Pur <Ali.mpfard@gmail.com> | 2021-09-10 20:46:50 +0430 |
commit | ecb3f882a3d617118b6d72e31fc0db4bb2c39769 (patch) | |
tree | fcf4fedeae34ef5b209ef37757b8325137dd17b2 /Userland | |
parent | 2a968e92f07a08df6cefccbe36b78fd84838d600 (diff) | |
download | serenity-ecb3f882a3d617118b6d72e31fc0db4bb2c39769.zip |
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.
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Libraries/LibFileSystemAccessClient/Client.cpp | 16 |
1 files 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 <LibGUI/WindowServerConnection.h> // clang-format on +#include <AK/LexicalPath.h> +#include <LibCore/File.h> #include <LibFileSystemAccessClient/Client.h> #include <LibGUI/Window.h> @@ -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(); } |