1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 20:47:45 +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

@ -349,9 +349,8 @@ void MainWidget::set_path(ByteString path)
update_title();
}
void MainWidget::save_to_file(String const& filename_string, NonnullOwnPtr<Core::File> file)
void MainWidget::save_to_file(ByteString const& filename, NonnullOwnPtr<Core::File> file)
{
auto filename = filename_string.to_byte_string();
auto theme = Core::ConfigFile::open(filename, move(file)).release_value_but_fixme_should_propagate_errors();
#define __ENUMERATE_ALIGNMENT_ROLE(role) theme->write_entry("Alignments", to_string(Gfx::AlignmentRole::role), to_string(m_current_palette.alignment(Gfx::AlignmentRole::role)));
@ -635,15 +634,15 @@ void MainWidget::show_path_picker_dialog(StringView property_display_name, GUI::
path_input.set_text(*result);
}
ErrorOr<void> MainWidget::load_from_file(String const& filename, NonnullOwnPtr<Core::File> file)
ErrorOr<void> MainWidget::load_from_file(ByteString const& filename, NonnullOwnPtr<Core::File> file)
{
auto config_file = TRY(Core::ConfigFile::open(filename.to_byte_string(), move(file)));
auto config_file = TRY(Core::ConfigFile::open(filename, move(file)));
auto theme = TRY(Gfx::load_system_theme(config_file));
VERIFY(theme.is_valid());
auto new_palette = Gfx::Palette(Gfx::PaletteImpl::create_with_anonymous_buffer(theme));
set_palette(move(new_palette));
set_path(filename.to_byte_string());
set_path(filename);
#define __ENUMERATE_ALIGNMENT_ROLE(role) \
if (auto alignment_input = m_alignment_inputs[to_underlying(Gfx::AlignmentRole::role)]) \
@ -677,7 +676,7 @@ ErrorOr<void> MainWidget::load_from_file(String const& filename, NonnullOwnPtr<C
m_last_modified_time = MonotonicTime::now();
window()->set_modified(false);
GUI::Application::the()->set_most_recently_open_file(filename.to_byte_string());
GUI::Application::the()->set_most_recently_open_file(filename);
return {};
}

View file

@ -86,7 +86,7 @@ public:
ErrorOr<void> initialize_menubar(GUI::Window&);
GUI::Window::CloseRequestDecision request_close();
void update_title();
ErrorOr<void> load_from_file(String const& filename, NonnullOwnPtr<Core::File> file);
ErrorOr<void> load_from_file(ByteString const& filename, NonnullOwnPtr<Core::File> file);
private:
explicit MainWidget(NonnullRefPtr<AlignmentModel>);
@ -94,7 +94,7 @@ private:
virtual void drag_enter_event(GUI::DragEvent&) override;
virtual void drop_event(GUI::DropEvent&) override;
void save_to_file(String const& filename, NonnullOwnPtr<Core::File> file);
void save_to_file(ByteString const& filename, NonnullOwnPtr<Core::File> file);
ErrorOr<Core::AnonymousBuffer> encode();
void set_path(ByteString);