Hello! I’m writing a Qt/c++ program that should write and read data on a file, while another process does the same. What file format should I use to prevent conflicts?
Hello! I’m writing a Qt/c++ program that should write and read data on a file, while another process does the same. What file format should I use to prevent conflicts?
The format has nothing to do with it. If two processes are writing to the same file at the same time it will be corrupted. You can either figure out a solution with locks (one process requests a lock on the file, the other process has to wait), or look into using SQLite which is most likely a better option if you can.
There are other solutions, such as writing to temp files. If you post more information it will be easier to give you the right advice. Why do more than one process need to write to the same file at the same time?
That’s not true. You just need to make sure the processes are writing to disjoint regions of the file. I wouldn’t recommend it unless you have a good reason though.
It still can corrupt due to certain factors like writes not immediately being propagated to disk. In theory it’s possible just harder than you’d think.