1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 14:27:35 +00:00

LibFileSystemAccessClient+Userland: Return file paths as ByteStrings

Where it was straightforward to do so, I've updated the users to also
use ByteStrings for their file paths, but most of them have a temporary
String::from_byte_string() call instead.
This commit is contained in:
Sam Atkins 2024-01-23 16:05:59 +00:00 committed by Sam Atkins
parent 5a99a6afb4
commit 44ca55aaf8
23 changed files with 50 additions and 53 deletions

View file

@ -145,8 +145,7 @@ void Client::handle_prompt_end(i32 request_id, i32 error, Optional<IPC::File> co
auto file_or_error = [&]() -> ErrorOr<File> {
auto stream = TRY(Core::File::adopt_fd(ipc_file->take_fd(), Core::File::OpenMode::ReadWrite));
auto filename = TRY(String::from_byte_string(*chosen_file));
return File({}, move(stream), filename);
return File({}, move(stream), *chosen_file);
}();
if (file_or_error.is_error()) {
auto maybe_message = String::formatted("{} \"{}\" failed: {}", action, *chosen_file, file_or_error.error());

View file

@ -31,7 +31,7 @@ enum ErrorFlag : u32 {
class Client;
class File {
public:
File(Badge<Client>, NonnullOwnPtr<Core::File> stream, String filename)
File(Badge<Client>, NonnullOwnPtr<Core::File> stream, ByteString filename)
: m_stream(move(stream))
, m_filename(filename)
{
@ -39,11 +39,11 @@ public:
Core::File& stream() const { return *m_stream; }
NonnullOwnPtr<Core::File> release_stream() { return move(m_stream); }
String filename() const { return m_filename; }
ByteString const& filename() const { return m_filename; }
private:
NonnullOwnPtr<Core::File> m_stream;
String m_filename;
ByteString m_filename;
};
using Result = ErrorOr<File>;