Mode

Specifies in what mode a file should be opened. These flags can be combined.

Values

ValueMeaning
none0

Default mode. Not very useful.

open1 << 0

Opens an existing file. Unless combined with create, fails if the file does not exist.

create1 << 1

Creates a new file. Fails if the file is opened without write access. Fails if the file already exists and not combined with truncate or open.

openOrCreateopen | create

Opens the file if it already exists or creates it if it does not.

append1 << 2

Allows only appending to the end of the file. Seek operations only affect subsequent reads. Upon writing, the file pointer gets set to the end of the file. Requires write access to the file.

truncate1 << 3

Truncates the file. This has no effect if the file has been created anew. Requires write access to the file.

Meta