mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-13 01:59:14 +03:00
lsof: Port to Core::Stream
This commit is contained in:
parent
9e4689f4c8
commit
376b5731a2
Notes:
sideshowbarker
2024-07-17 05:02:35 +09:00
Author: https://github.com/AtkinsSJ Commit: https://github.com/SerenityOS/serenity/commit/376b5731a2 Pull-request: https://github.com/SerenityOS/serenity/pull/15244 Reviewed-by: https://github.com/davidot ✅ Reviewed-by: https://github.com/demostanis
@ -11,8 +11,8 @@
|
||||
#include <AK/String.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/ProcessStatisticsReader.h>
|
||||
#include <LibCore/Stream.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <LibMain/Main.h>
|
||||
#include <ctype.h>
|
||||
@ -65,14 +65,18 @@ static bool parse_name(StringView name, OpenFile& file)
|
||||
|
||||
static Vector<OpenFile> get_open_files_by_pid(pid_t pid)
|
||||
{
|
||||
auto file = Core::File::open(String::formatted("/proc/{}/fds", pid), Core::OpenMode::ReadOnly);
|
||||
auto file = Core::Stream::File::open(String::formatted("/proc/{}/fds", pid), Core::Stream::OpenMode::Read);
|
||||
if (file.is_error()) {
|
||||
outln("lsof: PID {}: {}", pid, file.error());
|
||||
return Vector<OpenFile>();
|
||||
}
|
||||
auto data = file.value()->read_all();
|
||||
if (data.is_error()) {
|
||||
outln("lsof: PID {}: {}", pid, data.error());
|
||||
return {};
|
||||
}
|
||||
|
||||
auto json_or_error = JsonValue::from_string(data);
|
||||
auto json_or_error = JsonValue::from_string(data.value());
|
||||
if (json_or_error.is_error()) {
|
||||
outln("lsof: {}", json_or_error.error());
|
||||
return Vector<OpenFile>();
|
||||
|
Loading…
Reference in New Issue
Block a user