Two basic rules
- Opening in write mode always destroys an existing file.
- When open in append mode, writes always turn into appends, regardless of the current position
Instead of FILE_WRITE, there is no macro for what you need, which is read extended mode: "r+". The tricky part with that is if the file doesn't exist, it will just fail and not create it. There is no single mode that will create if necessary or open in read/write instead of append.
Since you have a bool create argument, that can control whether to open with FILE_WRITE or "r+"
More info on this in a post/thread a few months ago.