[SolutionArray] Enable appending to empty file

This commit is contained in:
Ingmar Schoegl
2025-09-07 18:52:55 -04:00
committed by Ray Speth
parent 7b7a5380f6
commit 304136ca6f
+2 -1
View File
@@ -1341,7 +1341,8 @@ void SolutionArray::save(const string& fname, const string& name, const string&
if (extension == "yaml" || extension == "yml") {
// Check for an existing file and load it if present
AnyMap data;
if (std::ifstream(fname).good()) {
std::ifstream file(fname);
if (file.good() && file.peek() != std::ifstream::traits_type::eof()) {
data = AnyMap::fromYamlFile(fname);
}
writeHeader(data, name, desc, overwrite);