When using fopen or fstream, it’s necessary to specify binary mode in order to prevent character conversions. On UNIX like systems this isn’t usually necessary but on Windows it is.
This leads me to wonder if this is still the “natural” way to access filesystem data on this operating system. UNIX has the “everything is a file” architecture going for it, so is there some windows equivalent of a lower level device to access the data? After all, if there are character conversions going on there’s the overhead involved in checking each character to see if it needs to be converted. Hopefully opening a file in binary mode would simply disable any such processing but I have my doubts.
Could anybody shed some light on this?
the C run-time libraries does what the C run-time libraries does.
Windows actually has most things as a file (or should I say objects) a file name in Windows is actually an object in the global namespace
\??\. If you look up the documentation forCreateFileon MSDN there’s a lot more to it, especially if you go digging through the Windows kernel documentation.If you’re curious about objects on Windows, you can also download and run
WinObjfrom technet.Depending on what type of project your working on, I’d put an abstraction layer around IO just to be able to fully utilize what’s in Windows but not in the C run-time libraries. I rarely write code for different platforms not going through the native API on each platform (or through some intermediary abstraction).