static assert(FileFlags("wb") == FileFlags.writeEmpty); static assert(FileFlags("wb+") == FileFlags.readWriteEmpty); static assert(FileFlags("w+b") == FileFlags.readWriteEmpty); static assert(FileFlags("wbx") == FileFlags.writeNew); static assert(FileFlags("wb+x") == FileFlags.readWriteNew); static assert(FileFlags("w+bx") == FileFlags.readWriteNew); static assert(FileFlags("rb") == FileFlags.readExisting); static assert(FileFlags("rb+") == FileFlags.readWriteExisting); static assert(FileFlags("r+b") == FileFlags.readWriteExisting); static assert(FileFlags("ab") == FileFlags(Mode.openOrCreate | Mode.append, Access.write)); static assert(FileFlags("ab+") == FileFlags(Mode.openOrCreate | Mode.append, Access.readWrite)); static assert(FileFlags("a+b") == FileFlags(Mode.openOrCreate | Mode.append, Access.readWrite));
Parses an fopen-style mode string such as "r+". All possible mode strings include:
The _mode strings accepted here differ from those accepted by fopen. Here, file streams are never opened in text _mode -- only binary mode. Text handling functionality is built on top of low-level file streams. It does not make sense to distinguish between text and binary modes here. fopen opens all files in text _mode by default and the flag 'b' must be specified in order to open in binary _mode. Thus, an exception is thrown here if 'b' is omitted in the specified mode string.
Note: It is not advisable to use fopen-style _mode strings. It is better to use one of the predefined file flag configurations such as FileFlags.readExisting for greater readability and intent of meaning.