diff options
author | Sam Atkins <atkinssj@serenityos.org> | 2022-09-14 12:02:33 +0100 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2022-11-19 17:00:10 +0000 |
commit | 7684e514dd9dd4b5ae69150005161ca10a337d5c (patch) | |
tree | e0121a57fa209d69259cc4b3650715646ea9e2fe /Userland/Utilities/du.cpp | |
parent | e08a42acd8dfa5f1e838d44aeef7c2affbe4ccfe (diff) | |
download | serenity-7684e514dd9dd4b5ae69150005161ca10a337d5c.zip |
du: Port to Core::Stream
Diffstat (limited to 'Userland/Utilities/du.cpp')
-rw-r--r-- | Userland/Utilities/du.cpp | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/Userland/Utilities/du.cpp b/Userland/Utilities/du.cpp index 2ffd84d6fa..baf93f7c49 100644 --- a/Userland/Utilities/du.cpp +++ b/Userland/Utilities/du.cpp @@ -11,12 +11,11 @@ #include <LibCore/ArgsParser.h> #include <LibCore/DateTime.h> #include <LibCore/DirIterator.h> -#include <LibCore/File.h> +#include <LibCore/Stream.h> #include <LibCore/System.h> #include <LibMain/Main.h> #include <limits.h> #include <string.h> -#include <sys/stat.h> struct DuOption { enum class TimeType { @@ -55,8 +54,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) ErrorOr<void> parse_args(Main::Arguments arguments, Vector<String>& files, DuOption& du_option) { bool summarize = false; - char const* pattern = nullptr; - char const* exclude_from = nullptr; + StringView pattern; + StringView exclude_from; Vector<StringView> files_to_process; Core::ArgsParser::Option time_option { @@ -112,11 +111,11 @@ ErrorOr<void> parse_args(Main::Arguments arguments, Vector<String>& files, DuOpt if (summarize) du_option.max_depth = 0; - if (pattern) + if (!pattern.is_empty()) du_option.excluded_patterns.append(pattern); - if (exclude_from) { - auto file = TRY(Core::File::open(exclude_from, Core::OpenMode::ReadOnly)); - auto const buff = file->read_all(); + if (!exclude_from.is_empty()) { + auto file = TRY(Core::Stream::File::open(exclude_from, Core::Stream::OpenMode::Read)); + auto const buff = TRY(file->read_all()); if (!buff.is_empty()) { String patterns = String::copy(buff, Chomp); du_option.excluded_patterns.extend(patterns.split('\n')); |