mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 06:57:46 +00:00
Browser: Convert file-downloading code to Core::Stream :^)
This commit is contained in:
parent
de3225a28b
commit
2b3790100a
2 changed files with 5 additions and 6 deletions
|
@ -8,9 +8,8 @@
|
|||
#include <AK/NumberFormat.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <LibConfig/Client.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/FileStream.h>
|
||||
#include <LibCore/StandardPaths.h>
|
||||
#include <LibCore/Stream.h>
|
||||
#include <LibDesktop/Launcher.h>
|
||||
#include <LibGUI/BoxLayout.h>
|
||||
#include <LibGUI/Button.h>
|
||||
|
@ -46,13 +45,13 @@ DownloadWidget::DownloadWidget(const URL& url)
|
|||
};
|
||||
|
||||
{
|
||||
auto file_or_error = Core::File::open(m_destination_path, Core::OpenMode::WriteOnly);
|
||||
auto file_or_error = Core::Stream::File::open(m_destination_path, Core::Stream::OpenMode::Write);
|
||||
if (file_or_error.is_error()) {
|
||||
GUI::MessageBox::show(window(), String::formatted("Cannot open {} for writing", m_destination_path), "Download failed", GUI::MessageBox::Type::Error);
|
||||
window()->close();
|
||||
return;
|
||||
}
|
||||
m_output_file_stream = make<Core::OutputFileStream>(*file_or_error.value());
|
||||
m_output_file_stream = file_or_error.release_value();
|
||||
}
|
||||
|
||||
m_download->on_finish = [this](bool success, auto) { did_finish(success); };
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
#include <AK/URL.h>
|
||||
#include <LibCore/ElapsedTimer.h>
|
||||
#include <LibCore/FileStream.h>
|
||||
#include <LibCore/Stream.h>
|
||||
#include <LibGUI/ImageWidget.h>
|
||||
#include <LibGUI/Progressbar.h>
|
||||
#include <LibGUI/Widget.h>
|
||||
|
@ -37,7 +37,7 @@ private:
|
|||
RefPtr<GUI::Button> m_close_button;
|
||||
RefPtr<GUI::CheckBox> m_close_on_finish_checkbox;
|
||||
RefPtr<GUI::ImageWidget> m_browser_image;
|
||||
OwnPtr<Core::OutputFileStream> m_output_file_stream;
|
||||
OwnPtr<Core::Stream::File> m_output_file_stream;
|
||||
Core::ElapsedTimer m_elapsed_timer;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue