mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 21:17:44 +00:00
Spreadsheet: Make save functions take a Core::File instead of a filename
This allows us to use FileSystemAccessClient functions.
This commit is contained in:
parent
04443eb847
commit
6a4b125fe5
4 changed files with 15 additions and 25 deletions
|
@ -64,25 +64,14 @@ Result<bool, String> Workbook::open_file(Core::File& file)
|
|||
return true;
|
||||
}
|
||||
|
||||
Result<bool, String> Workbook::save(StringView filename)
|
||||
Result<bool, String> Workbook::write_to_file(Core::File& file)
|
||||
{
|
||||
auto mime = Core::guess_mime_type_based_on_filename(filename);
|
||||
auto file = Core::File::construct(filename);
|
||||
file->open(Core::OpenMode::WriteOnly);
|
||||
if (!file->is_open()) {
|
||||
StringBuilder sb;
|
||||
sb.append("Failed to open ");
|
||||
sb.append(filename);
|
||||
sb.append(" for write. Error: ");
|
||||
sb.append(file->error_string());
|
||||
|
||||
return sb.to_string();
|
||||
}
|
||||
auto mime = Core::guess_mime_type_based_on_filename(file.filename());
|
||||
|
||||
// Make an export dialog, we might need to import it.
|
||||
TRY(ExportDialog::make_and_run_for(mime, *file, *this));
|
||||
TRY(ExportDialog::make_and_run_for(mime, file, *this));
|
||||
|
||||
set_filename(filename);
|
||||
set_filename(file.filename());
|
||||
set_dirty(false);
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue