From 6b4e17931ef10abfb53d97f463c85b5023c1f416 Mon Sep 17 00:00:00 2001 From: emeric Date: Mon, 10 Aug 2020 10:24:07 +0200 Subject: [PATCH] Early quit when no space left on device --- src/lms/main.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/lms/main.cpp b/src/lms/main.cpp index 3cdfa1a1..51244cc1 100644 --- a/src/lms/main.cpp +++ b/src/lms/main.cpp @@ -36,7 +36,9 @@ #include "utils/Service.hpp" #include "utils/WtLogger.hpp" -std::vector generateWtConfig(std::string execPath) +static +std::vector +generateWtConfig(std::string execPath) { std::vector args; @@ -92,8 +94,16 @@ std::vector generateWtConfig(std::string execPath) } - std::ofstream oss(wtConfigPath.string().c_str(), std::ios::out); - boost::property_tree::xml_parser::write_xml(oss, pt); + { + std::ofstream oss {wtConfigPath.string().c_str(), std::ios::out}; + if (!oss) + throw LmsException {"Can't open '" + wtConfigPath.string() + "' for writing!"}; + + boost::property_tree::xml_parser::write_xml(oss, pt); + + if (!oss) + throw LmsException {"Can't write in file '" + wtConfigPath.string() + "', no space left?"}; + } return args; }