mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 01:17:34 +00: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;
|
return return_code;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto file = Core::File::construct();
|
auto file_or_error = Core::Stream::File::adopt_fd(read_fd, Core::Stream::OpenMode::Read);
|
||||||
file->open(read_fd, Core::OpenMode::ReadOnly, Core::File::ShouldCloseFileDescriptor::Yes);
|
if (file_or_error.is_error()) {
|
||||||
auto data = DeprecatedString::copy(file->read_all());
|
warnln("\e[31mError:\e[0m Could not adopt file descriptor for reading: {}", file_or_error.error());
|
||||||
return data.split('\n');
|
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)
|
static bool run_system_command(DeprecatedString const& command, StringView command_name)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue