2

I have function that writes one section of ini file:

boolean saveSSVar()
{
    using boost::property_tree::ptree;


    ptree pt;
    pt.put(SRV_ID, ID);
    pt.put(SRV_LOG_LEVEL, LogLevel);



    write_ini( INI_FILE_NAME, pt );

    return true;
}

Problem is that it overwrites whole file instead one section. How to solve this problem?

vico
  • 17,051
  • 45
  • 159
  • 315

2 Answers2

1

Just

  1. read in original INI
  2. update values in ptree
  3. write resultant tree to INI

Note that not all information will roundtrip 100% (see the documentation for limitations)

See also: c++ boost library - writing to ini file without overwriting?

Community
  • 1
  • 1
sehe
  • 374,641
  • 47
  • 450
  • 633
0

Simplest way is to keep ptree as global or static.