Use O_BINARY when opening files if it is available

git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1354 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
psychon
2009-01-28 09:55:32 +00:00
parent 3ed2b755a3
commit e6ede6decb

View File

@@ -16,6 +16,10 @@
# define lstat(a, b) stat(a, b)
#endif
#ifndef O_BINARY
# define O_BINARY 0
#endif
CFile::CFile() {
m_iFD = -1;
m_bClose = false;
@@ -264,7 +268,13 @@ bool CFile::Open(int iFlags, mode_t iMode) {
}
// We never want to get a controlling TTY through this -> O_NOCTTY
m_iFD = open(m_sLongName.c_str(), iFlags | O_NOCTTY, iMode);
iMode |= O_NOCTTY;
// Some weird OS from MS needs O_BINARY or else it generates fake EOFs
// when reading ^Z from a file.
iMode |= O_BINARY;
m_iFD = open(m_sLongName.c_str(), iFlags, iMode);
if (m_iFD < 0)
return false;