summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibCore/ConfigFile.h
diff options
context:
space:
mode:
authorSam Atkins <atkinssj@serenityos.org>2022-02-06 15:27:17 +0000
committerTim Flynn <trflynn89@pm.me>2022-02-16 19:49:41 -0500
commite548aab387ecf9778fbb4b8393fb18f83b874c55 (patch)
tree467086044519842682727cd27ce52f5fff5af831 /Userland/Libraries/LibCore/ConfigFile.h
parentcd0ffe5460489744e41f8eceaa07e1dc29a85a06 (diff)
downloadserenity-e548aab387ecf9778fbb4b8393fb18f83b874c55.zip
LibCore: Migrate ConfigFile to Core::Stream API :^)
As part of this, moved the call to `reparse()` out of the constructor and into the factory methods, to allow the error to propagate.
Diffstat (limited to 'Userland/Libraries/LibCore/ConfigFile.h')
-rw-r--r--Userland/Libraries/LibCore/ConfigFile.h12
1 files changed, 7 insertions, 5 deletions
diff --git a/Userland/Libraries/LibCore/ConfigFile.h b/Userland/Libraries/LibCore/ConfigFile.h
index 14b149ff39..8e64d97b39 100644
--- a/Userland/Libraries/LibCore/ConfigFile.h
+++ b/Userland/Libraries/LibCore/ConfigFile.h
@@ -1,6 +1,7 @@
/*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2021, Jakob-Niklas See <git@nwex.de>
+ * Copyright (c) 2022, Sam Atkins <atkinssj@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -12,7 +13,7 @@
#include <AK/RefPtr.h>
#include <AK/String.h>
#include <AK/Vector.h>
-#include <LibCore/File.h>
+#include <LibCore/Stream.h>
#include <LibGfx/Color.h>
namespace Core {
@@ -57,14 +58,15 @@ public:
void remove_group(String const& group);
void remove_entry(String const& group, String const& key);
- String filename() const { return m_file->filename(); }
+ String const& filename() const { return m_filename; }
private:
- ConfigFile(String const& filename, NonnullRefPtr<File> open_file);
+ ConfigFile(String const& filename, OwnPtr<Stream::BufferedFile> open_file);
- void reparse();
+ ErrorOr<void> reparse();
- NonnullRefPtr<File> m_file;
+ String m_filename;
+ OwnPtr<Stream::BufferedFile> m_file;
HashMap<String, HashMap<String, String>> m_groups;
bool m_dirty { false };
};