Forgive my ignorance but what benefit would that have over using fileexists ?
It avoids a race condition. After FileExists() is called, someone else could come along and create/delete/access the file before you have a chance to call FileOpen()/FileCreate() yourself, so you might end up with access errors and/or corrupted data.
On Windows, CreateFile() has flags for:
- creating a new file only if it doesn't already exist.
- always creating a file, truncating an existing file.
- opening a file only if it exists.
- always opening a file, creating a new file if one does not exist.
These operations are atomic at the OS layer.
Linux's open()/fopen() has similar flags available.
So best to let the OS handle it with a single API call when possible, rather than handle it manually with multiple RTL function calls.