What happens if files are accessed simultaneously from different processes / threads? I understand that there is no standard way to lock a file, but only special functions.
In my case, files will often be read and written rarely. Now, if A open the file for reading (ifstream) and start reading fragments. And B opens the same file for writing (ofstream) and starts writing. What will happen? Is there any specific behavior?
change My goal is to simultaneously read, write to many files. But access to the recording will not occur very often. I would be pleased if fstreams guarantee that the contents of the file will not be confused.
etc .: Process 1 and 2 are written to file A. If they write at the same time, I am not interested if version 1 or 2 is written to disk, if it is a consistent version of the file.
If the process is reading the file and the other is writing it at the same time, I want the reading process to get the "old" version of the file.
If fstreams do not handle this, I will use the database.
source share