1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 12:38:12 +00:00

LibTimeZone: Port the TZDB generator to the stream API

This also moves the open_file helper to the utility file. It's currently
a lambda redefined in each TZDB/Unicode generator. It used to display
the missing command line flag and other info local to each generator.
After switching to LibMain, it just returns a generic error message, and
is duplicated several times.
This commit is contained in:
Timothy Flynn 2022-02-06 18:40:55 +00:00 committed by Tim Flynn
parent 6616e90cf6
commit 9327c2233f
2 changed files with 39 additions and 26 deletions

View file

@ -19,6 +19,7 @@
#include <AK/Vector.h>
#include <LibCore/DirIterator.h>
#include <LibCore/File.h>
#include <LibCore/Stream.h>
#include <LibUnicode/Locale.h>
template<class T>
@ -238,6 +239,15 @@ struct CanonicalLanguageID {
Vector<StringIndexType> variants {};
};
inline ErrorOr<NonnullOwnPtr<Core::Stream::BufferedFile>> open_file(StringView path, Core::Stream::OpenMode mode)
{
if (path.is_empty())
return Error::from_string_literal("Provided path is empty, please provide all command line options"sv);
auto file = TRY(Core::Stream::File::open(path, mode));
return Core::Stream::BufferedFile::create(move(file));
}
inline ErrorOr<Core::DirIterator> path_to_dir_iterator(String path, StringView subpath = "main"sv)
{
LexicalPath lexical_path(move(path));