From 7f902e33433e47b0c706be32edb90ec7c40e1b71 Mon Sep 17 00:00:00 2001 From: Nomango Date: Sun, 31 May 2020 22:10:49 +0800 Subject: [PATCH] update ConfigIni::Save --- src/kiwano/utils/ConfigIni.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/kiwano/utils/ConfigIni.cpp b/src/kiwano/utils/ConfigIni.cpp index f6fd924c..1ad2c3a9 100644 --- a/src/kiwano/utils/ConfigIni.cpp +++ b/src/kiwano/utils/ConfigIni.cpp @@ -158,16 +158,20 @@ bool ConfigIni::Save(std::ostream& os) std::sort(keys.begin(), keys.end()); // Output to ini - for (const auto& key : keys) + std::ostream::sentry ok(os); + if (ok) { - os << '[' << key << ']' << std::endl; - for (const auto& pair : sections_[key]) + for (const auto& key : keys) { - os << pair.first << " = " << pair.second << std::endl; + os << '[' << key << ']' << std::endl; + for (const auto& pair : sections_[key]) + { + os << pair.first << " = " << pair.second << std::endl; + } + os << std::endl; } - os << std::endl; } - return false; + return !os.fail(); } ConfigIni::SectionMap ConfigIni::GetSectionMap() const