简体   繁体   中英

Use “include” in a .ini config file

I need your help. I have two .ini-files with similar keys and values. I want them to be synchronized but more like merged.

There will be change on both sides of those .ini-files so we can't create a synchronisation cause we won't overwrite the other side. Everything should be merged/synchronized automatically, while we change content on both ini-files!

The goal is always to change a ini-file in our headquarter and merge/sync it with a file on our cash desk.

Example which cannot work:

ini-file1.ini , is on a cash desk and gets changed several times a day by the cash desk!

ini-file2.ini , is a dublicate of ini-file1.ini in our headquarter. We wanna be able to chnage ini-file2.ini during a change on the cash desk.

The cash desk changed the receiptnumber in ini-file1.ini and we (headquarter) changed key2 in ini-file2.ini :

ini-file1.ini:

 key1 = 1; key2 = 2; receiptnumber: 122 

ini-file2.ini:

 key1 = 1; key2 = 4; receiptnumber: 118 

And now we establish a synchronisation/merge between ini-file1.ini and ini-file2.ini .

A merge-application cannot know which of those keys is the proper key and which one to discard and overwrite.

Actually we thought we could investigate in a "insert/include" in one of those ini-files and outsource everything that comes from our second ini-file . So we got a object orieted ini-file. (My "ini-file oop concept")

Should mean:

ini-file1.ini , is on a cash desk and gets changed several times a day by the cash desk!

ini-file-outsource.ini , is just a part of the cash desk config file. We want it like attached to ini-file1.ini through a line like insert "C:\\ini-file-outsource.ini"; which doesn't exist, but we need something similar. It is everything which handles settings in the cashdesk, so this file is not changed by the cash desk. It's on the cash desk.

ini-file2.ini , is a dublicate of ini-file-outsource.ini . It's in our headquarter and used to change settings for the cash desk.

ini-file1.ini:

 key1 = 1; key2 = 2; receiptnumber: 122 insert "C:\\ini-file-outsource.ini"; 

ini-file-outsource.ini:

 key3 = 3; key4 = 4; key5 = 8; 

ini-file2.ini:

 key3 = 3; key4 = 4; key5 = 8; 

This time we establish a synchronisation between ini-file2.ini and ini-file-outsource.ini .

This should work if it's possible to achieve cause we change only different content on every side. Every key will be unique.

If you have any better approach I'm open for everything.

Thanks for your help

You can use something like:

ini=%d/../anotherFile.ini:section

Where %d is current file directory and :section refers to specific section to include

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM