The fopen() 'c' flag does not applicable to CreateFile(), in that it only applies a mode related to opening a file, not creating one.
For Linux, 'fopen()' the flags indicated in the question are as follows:
- "rb+c"
- r Open file for reading. The stream is positioned at the beginning of the file.
- b Strictly for compatibility with C89 and has no effect; the 'b' is ignored on all POSIX conforming systems, including Linux.
- + Extends the r flag (above) to also allow writing to the file.
- c Do not make the open operation, or subsequent read and write operations, thread cancellation points.
- "wb+c"
- w Open file for writing. The file is created if it does not exist, otherwise the file is truncated to zero length. The stream is positioned at the beginning of the file.
- b Strictly for compatibility with C89 and has no effect; the 'b' is ignored on all POSIX conforming systems, including Linux.
- + Extends the w flag (above) to also allow reading of the file.
- c Do not make the open operation, or subsequent read and write operations, thread cancellation points.
Translated to CreateFile():
- "rb+c" dwDesiredAccess
GENERIC_READ|GENERIC_WRITE
dwShareMode
FILE_SHARE_READ|FILE_SHARE_WRITE
dwCreationDisposition
OPEN_EXISTING
dwFlagsAdAttributes
FILE_ATTRIBUTE_NORMAL
CreateFile(
...,
GENERIC_READ|GENERIC_WRITE,
FILE_SHARE_READ|FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
...
);
GENERIC_READ|GENERIC_WRITE
dwShareMode
FILE_SHARE_READ|FILE_SHARE_WRITE
dwCreationDisposition
TRUNCATE_EXISTING|OPEN_ALWAYS
dwFlagsAdAttributes
FILE_ATTRIBUTE_NORMAL
CreateFile(
...
GENERIC_READ|GENERIC_WRITE,
FILE_SHARE_READ|FILE_SHARE_WRITE,
NULL,
TRUNCATE_EXISTING|OPEN_ALWAYS,
FILE_ATTRIBUTE_NORMAL,
...
);