- enum OpenMode { read, write, read_write, write_append, write_excl };
-
- /**
+ enum OpenMode {
+
+ /** Open file for reading or test if it can be opened for reading with Access() */
+ read,
+
+ /** Open file for writing deleting the contents of the file if it already exists
+ or test if it can be opened for writing with Access(). */
+ write,
+
+ /** Open file for reading and writing; cannot be used with Access() */
+ read_write,
+
+ /** Open file for appending: the file is opened for writing, but the old contents
+ of the file are not erased and the file pointer is initially placed at the end
+ of the file; cannot be used with Access().
+
+ This is the same as OpenMode::write if the file doesn't exist.
+ */
+ write_append,
+
+ /**
+ Open the file securely for writing (Uses O_EXCL | O_CREAT).
+ Will fail if the file already exists, else create and open it atomically.
+ Useful for opening temporary files without being vulnerable to race exploits.
+ */
+ write_excl
+ };
+
+ /**