mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-23 18:02:05 -05:00
ConfigureComponents: Use Core::Stream
to read output from whiptail
This commit is contained in:
parent
558fab2703
commit
9ec2cb3741
1 changed files with 11 additions and 4 deletions
|
@ -192,10 +192,17 @@ static Result<Vector<DeprecatedString>, int> run_whiptail(WhiptailMode mode, Vec
|
|||
return return_code;
|
||||
}
|
||||
|
||||
auto file = Core::File::construct();
|
||||
file->open(read_fd, Core::OpenMode::ReadOnly, Core::File::ShouldCloseFileDescriptor::Yes);
|
||||
auto data = DeprecatedString::copy(file->read_all());
|
||||
return data.split('\n');
|
||||
auto file_or_error = Core::Stream::File::adopt_fd(read_fd, Core::Stream::OpenMode::Read);
|
||||
if (file_or_error.is_error()) {
|
||||
warnln("\e[31mError:\e[0m Could not adopt file descriptor for reading: {}", file_or_error.error());
|
||||
return -1;
|
||||
}
|
||||
auto data_or_error = file_or_error.value()->read_until_eof();
|
||||
if (data_or_error.is_error()) {
|
||||
warnln("\e[31mError:\e[0m Could not read data from file descriptor: {}", data_or_error.error());
|
||||
return -1;
|
||||
}
|
||||
return DeprecatedString::copy(data_or_error.value()).split('\n');
|
||||
}
|
||||
|
||||
static bool run_system_command(DeprecatedString const& command, StringView command_name)
|
||||
|
|
Loading…
Add table
Reference in a new issue