@@ -191,6 +191,11 @@ Settings::Settings(const string dir_binary, const string dir_settings)
191191 }
192192 in.close ();
193193 }
194+ if (settings_.first .empty ())
195+ {
196+ // could work if all arguments were specified as cli args (not currently possible)
197+ logging::warning (" Settings file %s is empty" , filename.c_str ());
198+ }
194199 if (const auto value = get_value (settings_, " OUTPUT_DIRECTORY" , false ); " INVALID" != value)
195200 {
196201 output_directory = value;
@@ -359,10 +364,12 @@ Settings::Settings(const string dir_binary, const string dir_settings)
359364}
360365void Settings::saveTo (const string& output_directory) const noexcept
361366{
367+ make_directory_recursive (output_directory.c_str ());
362368 const pushd dir{output_directory};
363369 const auto filename = string (output_directory) + " settings.ini" ;
364370 ofstream out{filename};
365371 auto put = [&](const string& key, const string& comment, const auto & value) {
372+ // FIX: use original string instead of parsed and stringified input so nothing can change
366373 static constexpr auto MAX_PRECISION = std::numeric_limits<double >::digits10 + 1 ;
367374 // make sure we don't lose precision or results will differ when run with settings file
368375 out << " # " << comment << " \n " ;
@@ -373,7 +380,6 @@ void Settings::saveTo(const string& output_directory) const noexcept
373380 // auto abs = std::filesystem::absolute(output_directory).lexically_normal();
374381 auto abs = dir.current_directory ;
375382 auto relative = [&](const string& path) {
376- const pushd dir{output_directory};
377383 // return std::filesystem::relative(path.c_str(), abs.c_str());
378384 return std::filesystem::relative (path.c_str ());
379385 // return path;
0 commit comments