I am working on some legacy code which opens a file and adds binary data to the file:
std::ifstream mInFile;
#ifdef WINDOWS
miWindowsFileHandle = _sopen(filename.c_str(), O_RDONLY , SH_DENYWR, S_IREAD);
#endif
mInFile.open(filename.c_str(), std::ios_base::binary);
For some reason the code opens the file twice. Is this because _sopen is used to lock the file in windows?
If so, how come std::ifstream::open doesn't lock the file?
Is there a way to check if a windows file handle has already been closed?