1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 16:07:47 +00:00

FileManager: Use Core::Stream for FileOperationProgressWidget

This commit is contained in:
Sam Atkins 2022-03-12 13:45:03 +00:00 committed by Andreas Kling
parent dc5a318aa9
commit 1925bde3c0
3 changed files with 16 additions and 11 deletions

View file

@ -18,7 +18,7 @@
namespace FileManager {
FileOperationProgressWidget::FileOperationProgressWidget(FileOperation operation, NonnullRefPtr<Core::File> helper_pipe)
FileOperationProgressWidget::FileOperationProgressWidget(FileOperation operation, NonnullOwnPtr<Core::Stream::BufferedFile> helper_pipe, int helper_pipe_fd)
: m_operation(operation)
, m_helper_pipe(move(helper_pipe))
{
@ -69,14 +69,17 @@ FileOperationProgressWidget::FileOperationProgressWidget(FileOperation operation
VERIFY_NOT_REACHED();
}
m_notifier = Core::Notifier::construct(m_helper_pipe->fd(), Core::Notifier::Read);
m_notifier = Core::Notifier::construct(helper_pipe_fd, Core::Notifier::Read);
m_notifier->on_ready_to_read = [this] {
auto line = m_helper_pipe->read_line();
if (line.is_null()) {
auto line_buffer = ByteBuffer::create_zeroed(1 * KiB).release_value_but_fixme_should_propagate_errors();
auto line_length_or_error = m_helper_pipe->read_line(line_buffer.bytes());
if (line_length_or_error.is_error() || line_length_or_error.value() == 0) {
did_error("Read from pipe returned null."sv);
return;
}
StringView line { line_buffer.bytes().data(), line_length_or_error.value() };
auto parts = line.split_view(' ');
VERIFY(!parts.is_empty());