From 9ea3c2d3ee05a791e1760c1b18d791490a1caab7 Mon Sep 17 00:00:00 2001 From: Adam Gundy Date: Thu, 8 May 2003 21:02:31 +0000 Subject: [PATCH] _open_osfhandle is expected to take the absence of either _O_TEXT or _O_BINARY to mean _O_BINARY. --- dlls/msvcrt/file.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/dlls/msvcrt/file.c b/dlls/msvcrt/file.c index bcd7e36f7f6..47c2f8f4820 100644 --- a/dlls/msvcrt/file.c +++ b/dlls/msvcrt/file.c @@ -1124,13 +1124,19 @@ int _wcreat(const MSVCRT_wchar_t *path, int flags) */ int _open_osfhandle(long hand, int flags) { + int fd; + /* _O_RDONLY (0) always matches, so set the read flag * MFC's CStdioFile clears O_RDONLY (0)! if it wants to write to the - * file, so set the write flag + * file, so set the write flag. It also only sets _O_TEXT if it wants + * text - it never sets _O_BINARY. */ /* FIXME: handle more flags */ - int fd= msvcrt_alloc_fd((HANDLE)hand,flags|MSVCRT__IOREAD|MSVCRT__IOWRT); - TRACE(":handle (%ld) fd (%d) flags 0x%08x\n",hand,fd, flags |MSVCRT__IOREAD|MSVCRT__IOWRT); + flags |= MSVCRT__IOREAD|MSVCRT__IOWRT; + if ( !( flags & _O_TEXT ) ) flags |= _O_BINARY; + + fd = msvcrt_alloc_fd((HANDLE)hand,flags); + TRACE(":handle (%ld) fd (%d) flags 0x%08x\n",hand,fd, flags); return fd; } -- 2.11.4.GIT