What will happen if files are accessed concurrently from different processes/threads? I understand there is no standard way of locking a file, only os specific functions.
In my case files will be read often and written seldom.
Now if A
open a file for reading (ifstream) and starts reading chunks. And B
opens the same file for writing (ofstream) and starts writing. What will happen? Is there a defined behavior?
edit My goal is concurrent read, write access to many files. But write access will not occur very often. I would be content if the fstreams guarantee that file content doesn't get mixed up.
E.g.: Process 1 and 2 write to file A. If they write concurrently I dont't care if the version of 1 or 2 is written to disc, as long as it is a consistent version of the file.
If a process reads a file and another writes to it at the same time, I want the reading process to get the "old" version of the file.
If fstreams don't handle this I will use a database.