Why Createfile () Does Not Have a Binary Flag

One of the greatest joys of Windows programming is remembering that in all open file calls you need to put 'wb' or 'rb' or ios :: binary so that Windows doesn’t convert all your 0x13s in a fun way.

I just had to convert a bunch of well-standard code to use Createfile () to get a specific flag - and it occurred to me that there was no way to specify a binary.
How to know this? I really don't want it to change the bytes in my MP4 stream, thanks very very much.

+6
c ++ winapi
source share
3 answers

Since CreateFile does not perform text mode / newline conversions. They are processed at a higher level, either in FILE for CRT, or iostreams for C ++.

+8
source share

Everything is binary in relation to the Windows API. Personally, I prefer that. I never use text mode in the standard library.

+6
source share

You cannot specify a binary or text flag, because for Windows all files are binary! The wb and rb parameters are entered as subtlety, as part of the C IO stream functions, and even then only in DOS / Windows to help the developer read and write text files and perform CR / LF to LF conversion.

+1
source share

All Articles