The user is supposed to convert the binary data into a JSON-representation (either as a file or in memory), modify it as required and then convert JSON back into the binary format.
The user? Aren't you writing a program to do this?
Or does the program convert binary to JSON; present the JSON for interactive modification; and then when the user's finished; convert their modified JSON back to binary and rewrite the file in-place?
It seems to me that most of your envisioned potential problems would go away if you split the process into 3 separate processes.
What to do if the original has changed in the intervening period is a 'production processes' problem. Ie. Managerial not technological.
I'm reading a file. It's always possible someone is doing something stupif(1) and modifying / replacing the file while the tool is parsing it. A big fat "DON'T DO THAT" sticker is probably sufficient, but it would be nice to limit the exposure. Another way could be to calculate the file size / date / md5sum before and after parsing and repeat the parse if it changed unexpectedly.
You seem to be looking for complicated solutions to "shouldn't happen" possibilities.
A simpler solution would be to move (rename) the file to a 'this user only' permissions directory; or change the permissions on the file to 'this user only'; or investigate use mandatory locking if that's available on your platform.
In reply to Re^3: Deciding for a file access method - requesting opinions
by BrowserUk
in thread Deciding for a file access method - requesting opinions
by Monk::Thomas
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |