From 8a8ad81aa13ec25d20d78bf99f951055ef416597 Mon Sep 17 00:00:00 2001 From: Sam Atkins Date: Wed, 15 Mar 2023 14:56:20 +0000 Subject: LibUnicode: Migrate GenerateEmojiData to Directory::for_each_entry() --- .../CodeGenerators/LibUnicode/GenerateEmojiData.cpp | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'Meta/Lagom/Tools') diff --git a/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateEmojiData.cpp b/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateEmojiData.cpp index 66b79d15d4..09a3dab1c0 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateEmojiData.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateEmojiData.cpp @@ -13,7 +13,6 @@ #include #include #include -#include #include #include @@ -171,14 +170,10 @@ static ErrorOr parse_emoji_serenity_data(Core::BufferedFile& file, EmojiDa static ErrorOr validate_emoji(StringView emoji_resource_path, EmojiData& emoji_data) { - Core::DirIterator iterator(emoji_resource_path, Core::DirIterator::SkipDots); - - while (iterator.has_next()) { - auto filename = iterator.next_path(); - - auto lexical_path = LexicalPath(filename); + TRY(Core::Directory::for_each_entry(emoji_resource_path, Core::DirIterator::SkipDots, [&](auto& entry, auto&) -> ErrorOr { + auto lexical_path = LexicalPath(entry.name); if (lexical_path.extension() != "png") - continue; + return IterationDecision::Continue; auto title = lexical_path.title(); if (!title.starts_with("U+"sv)) @@ -198,10 +193,12 @@ static ErrorOr validate_emoji(StringView emoji_resource_path, EmojiData& e }); if (it == emoji_data.emojis.end()) { - warnln("\x1b[1;31mError!\x1b[0m Emoji data for \x1b[35m{}\x1b[0m not found. Please check emoji-test.txt and emoji-serenity.txt.", filename); + warnln("\x1b[1;31mError!\x1b[0m Emoji data for \x1b[35m{}\x1b[0m not found. Please check emoji-test.txt and emoji-serenity.txt.", entry.name); return Error::from_errno(ENOENT); } - } + + return IterationDecision::Continue; + })); return {}; } -- cgit v1.2.3