From e6ede6decb80de42ca06a9aa916d27ada8e6f73b Mon Sep 17 00:00:00 2001 From: psychon Date: Wed, 28 Jan 2009 09:55:32 +0000 Subject: [PATCH] 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 --- FileUtils.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/FileUtils.cpp b/FileUtils.cpp index 25866923..fe7f116e 100644 --- a/FileUtils.cpp +++ b/FileUtils.cpp @@ -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;