MCPcopy Create free account
hub / github.com/OpenFodder/openfodder / save

Method save

Source/Utils/ini.hpp:410–442  ·  view source on GitHub ↗

Output Save from memory into file

Source from the content-addressed store, hash-verified

408 ///Output
409 //Save from memory into file
410 bool save(const std::string filename = "")
411 {
412 if (!hasFileAssociation(filename))
413 return false;
414
415 fini_ofstream_t file(((filename == "") ? this->filename : filename).c_str(), std::ios::trunc);
416 if (!file.is_open())
417 return false;
418
419 //Loop through sections
420 for (typename INI::sectionsit_t i = sections.begin(); i != sections.end(); i++)
421 {
422 if (i->second->size() == 0) //No keys/values in section, skip to next
423 continue;
424
425 //Write section
426 const fini_string_t temp = makeSection(i->first);
427 const fini_char_t* line = temp.c_str();
428 file.write(line, fini_strlen(line));
429
430 for (typename INI::keysit_t j = i->second->begin(); j != i->second->end(); j++)
431 {
432 //Write key and value
433 const fini_string_t temp = makeKeyValue(j->first, j->second);
434 const fini_char_t* line = temp.c_str();
435 file.write(line, fini_strlen(line));
436 }
437 }
438
439 file.close();
440
441 return true;
442 }
443
444 //Saves it without any conventional INI formatting characters, however it only uses string streams
445 bool saveBinary(const std::string filename = "")

Callers

nothing calls this directly

Calls 4

closeMethod · 0.80
beginMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected