1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 21:58:12 +00:00

LibFileSystemAccessClient+CrashReporter: Introduce FSAC::File and use it

The new result returned just a file stream, which wasn't sufficient
enough for most applications because it didn't provide a filename.

This patch will make a new File object that has both a file stream and
a filename.
This commit is contained in:
Karol Kosek 2022-12-16 23:15:12 +01:00 committed by Sam Atkins
parent 247db3fdd0
commit 2cbe2dd3c0
3 changed files with 27 additions and 3 deletions

View file

@ -8,6 +8,7 @@
#pragma once
#include <AK/HashMap.h>
#include <AK/String.h>
#include <FileSystemAccessServer/FileSystemAccessClientEndpoint.h>
#include <FileSystemAccessServer/FileSystemAccessServerEndpoint.h>
#include <LibCore/File.h>
@ -18,8 +19,26 @@
namespace FileSystemAccessClient {
class Client;
class File {
public:
File(Badge<Client>, NonnullOwnPtr<Core::Stream::File> stream, String filename)
: m_stream(move(stream))
, m_filename(filename)
{
}
Core::Stream::File& stream() const { return *m_stream; }
NonnullOwnPtr<Core::Stream::File> release_stream() { return move(m_stream); }
String filename() const { return m_filename; }
private:
NonnullOwnPtr<Core::Stream::File> m_stream;
String m_filename;
};
using DeprecatedResult = ErrorOr<NonnullRefPtr<Core::File>>;
using Result = ErrorOr<NonnullOwnPtr<Core::Stream::File>>;
using Result = ErrorOr<File>;
class Client final
: public IPC::ConnectionToServer<FileSystemAccessClientEndpoint, FileSystemAccessServerEndpoint>