diff --git a/Userland/Applications/Spreadsheet/ImportDialog.cpp b/Userland/Applications/Spreadsheet/ImportDialog.cpp index d37a3c4722..bcf82d5122 100644 --- a/Userland/Applications/Spreadsheet/ImportDialog.cpp +++ b/Userland/Applications/Spreadsheet/ImportDialog.cpp @@ -177,7 +177,7 @@ void CSVImportDialogPage::update_preview() m_data_preview_table_view->update(); } -ErrorOr>, ByteString> ImportDialog::make_and_run_for(GUI::Window& parent, StringView mime, String const& filename, Core::File& file, Workbook& workbook) +ErrorOr>, ByteString> ImportDialog::make_and_run_for(GUI::Window& parent, StringView mime, ByteString const& filename, Core::File& file, Workbook& workbook) { auto wizard = GUI::WizardDialog::create(&parent).release_value_but_fixme_should_propagate_errors(); wizard->set_title("File Import Wizard"); @@ -247,7 +247,7 @@ ErrorOr>, ByteString> ImportDialog::make_and_run_for } else { auto page = GUI::WizardPage::create( "Import File Format"sv, - ByteString::formatted("Select the format you wish to import '{}' as", LexicalPath::basename(filename.to_byte_string()))) + ByteString::formatted("Select the format you wish to import '{}' as", LexicalPath::basename(filename))) .release_value_but_fixme_should_propagate_errors(); page->on_next_page = [] { return nullptr; }; diff --git a/Userland/Applications/Spreadsheet/ImportDialog.h b/Userland/Applications/Spreadsheet/ImportDialog.h index f9e6c00bcc..6d2286e09f 100644 --- a/Userland/Applications/Spreadsheet/ImportDialog.h +++ b/Userland/Applications/Spreadsheet/ImportDialog.h @@ -55,7 +55,7 @@ private: }; struct ImportDialog { - static ErrorOr>, ByteString> make_and_run_for(GUI::Window& parent, StringView mime, String const& filename, Core::File& file, Workbook&); + static ErrorOr>, ByteString> make_and_run_for(GUI::Window& parent, StringView mime, ByteString const& filename, Core::File& file, Workbook&); }; } diff --git a/Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp b/Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp index 1888b2544e..f5521360e0 100644 --- a/Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp +++ b/Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp @@ -136,7 +136,7 @@ SpreadsheetWidget::SpreadsheetWidget(GUI::Window& parent_window, Vectorcolor()); } -void SpreadsheetWidget::save(String const& filename, Core::File& file) +void SpreadsheetWidget::save(ByteString const& filename, Core::File& file) { auto result = m_workbook->write_to_file(filename, file); if (result.is_error()) { @@ -569,10 +569,10 @@ void SpreadsheetWidget::save(String const& filename, Core::File& file) } undo_stack().set_current_unmodified(); 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); } -void SpreadsheetWidget::load_file(String const& filename, Core::File& file) +void SpreadsheetWidget::load_file(ByteString const& filename, Core::File& file) { auto result = m_workbook->open_file(filename, file); if (result.is_error()) { @@ -592,10 +592,10 @@ void SpreadsheetWidget::load_file(String const& filename, Core::File& file) setup_tabs(m_workbook->sheets()); update_window_title(); - GUI::Application::the()->set_most_recently_open_file(filename.to_byte_string()); + GUI::Application::the()->set_most_recently_open_file(filename); } -void SpreadsheetWidget::import_sheets(String const& filename, Core::File& file) +void SpreadsheetWidget::import_sheets(ByteString const& filename, Core::File& file) { auto result = m_workbook->import_file(filename, file); if (result.is_error()) { @@ -733,7 +733,7 @@ ErrorOr SpreadsheetWidget::initialize_menubar(GUI::Window& window) auto response = FileSystemAccessClient::Client::the().request_file_read_only_approved(&window, action.text()); if (response.is_error()) return; - load_file(MUST(String::from_byte_string(response.value().filename())), response.value().stream()); + load_file(response.value().filename(), response.value().stream()); }); file_menu->add_action(*m_quit_action); diff --git a/Userland/Applications/Spreadsheet/SpreadsheetWidget.h b/Userland/Applications/Spreadsheet/SpreadsheetWidget.h index d99ac857d2..bdffab1411 100644 --- a/Userland/Applications/Spreadsheet/SpreadsheetWidget.h +++ b/Userland/Applications/Spreadsheet/SpreadsheetWidget.h @@ -22,9 +22,9 @@ class SpreadsheetWidget final public: virtual ~SpreadsheetWidget() override = default; - void save(String const& filename, Core::File&); - void load_file(String const& filename, Core::File&); - void import_sheets(String const& filename, Core::File&); + void save(ByteString const& filename, Core::File&); + void load_file(ByteString const& filename, Core::File&); + void import_sheets(ByteString const& filename, Core::File&); bool request_close(); void add_sheet(); void add_sheet(NonnullRefPtr&&); diff --git a/Userland/Applications/Spreadsheet/Workbook.cpp b/Userland/Applications/Spreadsheet/Workbook.cpp index f2c8b40fe5..8c73611265 100644 --- a/Userland/Applications/Spreadsheet/Workbook.cpp +++ b/Userland/Applications/Spreadsheet/Workbook.cpp @@ -50,31 +50,31 @@ bool Workbook::set_filename(ByteString const& filename) return true; } -ErrorOr Workbook::open_file(String const& filename, Core::File& file) +ErrorOr Workbook::open_file(ByteString const& filename, Core::File& file) { auto mime = Core::guess_mime_type_based_on_filename(filename); // Make an import dialog, we might need to import it. m_sheets = TRY(ImportDialog::make_and_run_for(m_parent_window, mime, filename, file, *this)); - set_filename(filename.to_byte_string()); + set_filename(filename); return {}; } -ErrorOr Workbook::write_to_file(String const& filename, Core::File& stream) +ErrorOr Workbook::write_to_file(ByteString const& filename, Core::File& stream) { auto mime = Core::guess_mime_type_based_on_filename(filename); // Make an export dialog, we might need to import it. - TRY(ExportDialog::make_and_run_for(mime, stream, filename.to_byte_string(), *this)); + TRY(ExportDialog::make_and_run_for(mime, stream, filename, *this)); - set_filename(filename.to_byte_string()); + set_filename(filename); set_dirty(false); return {}; } -ErrorOr Workbook::import_file(String const& filename, Core::File& file) +ErrorOr Workbook::import_file(ByteString const& filename, Core::File& file) { auto mime = Core::guess_mime_type_based_on_filename(filename); diff --git a/Userland/Applications/Spreadsheet/Workbook.h b/Userland/Applications/Spreadsheet/Workbook.h index 70dbb47d97..bf2d4706fe 100644 --- a/Userland/Applications/Spreadsheet/Workbook.h +++ b/Userland/Applications/Spreadsheet/Workbook.h @@ -15,10 +15,10 @@ class Workbook { public: Workbook(Vector>&& sheets, GUI::Window& parent_window); - ErrorOr open_file(String const& filename, Core::File&); - ErrorOr write_to_file(String const& filename, Core::File&); + ErrorOr open_file(ByteString const& filename, Core::File&); + ErrorOr write_to_file(ByteString const& filename, Core::File&); - ErrorOr import_file(String const& filename, Core::File&); + ErrorOr import_file(ByteString const& filename, Core::File&); ByteString const& current_filename() const { return m_current_filename; } bool set_filename(ByteString const& filename); diff --git a/Userland/Applications/Spreadsheet/main.cpp b/Userland/Applications/Spreadsheet/main.cpp index fbc345d84a..9f69f9426f 100644 --- a/Userland/Applications/Spreadsheet/main.cpp +++ b/Userland/Applications/Spreadsheet/main.cpp @@ -71,7 +71,7 @@ ErrorOr serenity_main(Main::Arguments arguments) if (!filename.is_empty()) { auto file = TRY(FileSystemAccessClient::Client::the().request_file_read_only_approved(window, filename)); - spreadsheet_widget->load_file(TRY(String::from_byte_string(file.filename())), file.stream()); + spreadsheet_widget->load_file(file.filename(), file.stream()); } return app->exec();