Dave's Brain

Browse - Programming Tips - Best practices when updating a shared .ini file?

Date: 2014dec9

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.

In summary:
- 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

Add a comment

Sign in to add a comment
Copyright © 2008-2018, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.