mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:17:45 +00:00
LibFileSystemAccessClient: Add save_file()
This method replaces `try_save_file_deprecated()`, as it has the same behavior but returns a `Core::Stream::File` instead.
This commit is contained in:
parent
cfb0e1bdb2
commit
6dd716adf2
2 changed files with 73 additions and 27 deletions
|
@ -19,6 +19,7 @@
|
|||
namespace FileSystemAccessClient {
|
||||
|
||||
using DeprecatedResult = ErrorOr<NonnullRefPtr<Core::File>>;
|
||||
using Result = ErrorOr<NonnullOwnPtr<Core::Stream::File>>;
|
||||
|
||||
class Client final
|
||||
: public IPC::ConnectionToServer<FileSystemAccessClientEndpoint, FileSystemAccessServerEndpoint>
|
||||
|
@ -31,6 +32,8 @@ public:
|
|||
DeprecatedResult try_open_file(GUI::Window* parent_window, DeprecatedString const& window_title = {}, StringView path = Core::StandardPaths::home_directory(), Core::OpenMode requested_access = Core::OpenMode::ReadOnly);
|
||||
DeprecatedResult try_save_file_deprecated(GUI::Window* parent_window, DeprecatedString const& name, DeprecatedString const ext, Core::OpenMode requested_access = Core::OpenMode::WriteOnly | Core::OpenMode::Truncate);
|
||||
|
||||
Result save_file(GUI::Window* parent_window, DeprecatedString const& name, DeprecatedString const ext, Core::Stream::OpenMode requested_access = Core::Stream::OpenMode::Write | Core::Stream::OpenMode::Truncate);
|
||||
|
||||
static Client& the();
|
||||
|
||||
protected:
|
||||
|
@ -45,10 +48,14 @@ private:
|
|||
virtual void handle_prompt_end(i32 request_id, i32 error, Optional<IPC::File> const& fd, Optional<DeprecatedString> const& chosen_file) override;
|
||||
|
||||
int get_new_id();
|
||||
DeprecatedResult handle_promise(int);
|
||||
template<typename AnyResult>
|
||||
AnyResult handle_promise(int);
|
||||
|
||||
template<typename T>
|
||||
using PromiseType = RefPtr<Core::Promise<T>>;
|
||||
|
||||
struct PromiseAndWindow {
|
||||
RefPtr<Core::Promise<DeprecatedResult>> promise {};
|
||||
Variant<PromiseType<DeprecatedResult>, PromiseType<Result>> promise;
|
||||
GUI::Window* parent_window { nullptr };
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue