summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibCore
diff options
context:
space:
mode:
authorSam Atkins <atkinssj@serenityos.org>2022-02-06 14:26:33 +0000
committerTim Flynn <trflynn89@pm.me>2022-02-16 19:49:41 -0500
commitcd0ffe5460489744e41f8eceaa07e1dc29a85a06 (patch)
treeffb7b600ecfa2ca5e7db78a2161a33c9fd8edfbb /Userland/Libraries/LibCore
parentb90dc408bdd249ca04f10cf0d288e6f8549e9832 (diff)
downloadserenity-cd0ffe5460489744e41f8eceaa07e1dc29a85a06.zip
LibCore+Everywhere: Return ErrorOr from ConfigFile::sync()
Currently this method always succeeds, but that won't be true once we switch to the Core::Stream API. :^) Some of these places would ideally show an error message to the user, since failure to save a file is significant, but let's not get distracted right now.
Diffstat (limited to 'Userland/Libraries/LibCore')
-rw-r--r--Userland/Libraries/LibCore/ConfigFile.cpp8
-rw-r--r--Userland/Libraries/LibCore/ConfigFile.h2
2 files changed, 5 insertions, 5 deletions
diff --git a/Userland/Libraries/LibCore/ConfigFile.cpp b/Userland/Libraries/LibCore/ConfigFile.cpp
index 78a75a398b..ec2fb3007b 100644
--- a/Userland/Libraries/LibCore/ConfigFile.cpp
+++ b/Userland/Libraries/LibCore/ConfigFile.cpp
@@ -61,7 +61,7 @@ ConfigFile::ConfigFile(String const&, NonnullRefPtr<File> open_file)
ConfigFile::~ConfigFile()
{
- sync();
+ MUST(sync());
}
void ConfigFile::reparse()
@@ -168,10 +168,10 @@ void ConfigFile::write_color_entry(String const& group, String const& key, Color
write_entry(group, key, String::formatted("{},{},{},{}", value.red(), value.green(), value.blue(), value.alpha()));
}
-bool ConfigFile::sync()
+ErrorOr<void> ConfigFile::sync()
{
if (!m_dirty)
- return true;
+ return {};
m_file->truncate(0);
m_file->seek(0);
@@ -184,7 +184,7 @@ bool ConfigFile::sync()
}
m_dirty = false;
- return true;
+ return {};
}
void ConfigFile::dump() const
diff --git a/Userland/Libraries/LibCore/ConfigFile.h b/Userland/Libraries/LibCore/ConfigFile.h
index 00da8d8346..14b149ff39 100644
--- a/Userland/Libraries/LibCore/ConfigFile.h
+++ b/Userland/Libraries/LibCore/ConfigFile.h
@@ -52,7 +52,7 @@ public:
bool is_dirty() const { return m_dirty; }
- bool sync();
+ ErrorOr<void> sync();
void remove_group(String const& group);
void remove_entry(String const& group, String const& key);