Browse - Programming Tips - Best practices when updating a shared .ini file?
Q. Best practices when updating a shared .ini file?
1. Make sure all updates to the thefile.ini file are done atomically.
ie write to a temp name and rename to thefile.ini.
1B. Do not use thefile.ini.new as the temp name because somebody else might
use that. Use the name of the updating app in the temp name.
eg thefile.ini.app1_new or thefile.ini.app2_new
2. Apps which update the .ini file should not delete or change
fields/sections they don't know about.
Unknown fields and sections should be preserved during updates.
- Read in the the .ini file preserving everything
- Make the update in memory
- Write it out to thefile.ini.theapp_new
- Rename to thefile.ini