X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=GHC%2FHandle.hs;h=52bf8cde99e4de0877b07139144ee74ea924c067;hb=b674b3cdb447d2265dccc4e3c343c9625f464a33;hp=0e9b3be0a957ede3b356cbc61c4d17495525406e;hpb=956ef5fcd15bee4981eec3e666891b3f63c8b345;p=haskell-directory.git diff --git a/GHC/Handle.hs b/GHC/Handle.hs index 0e9b3be..52bf8cd 100644 --- a/GHC/Handle.hs +++ b/GHC/Handle.hs @@ -924,16 +924,21 @@ openFd fd mb_fd_type is_socket filepath mode binary = do "file is locked" Nothing) #endif mkFileHandle fd is_socket filepath ha_type binary - -- Stream or RawDevice - Stream -> mkIt ha_type - RawDevice -> mkIt ha_type + + Stream + -- only *Streams* can be DuplexHandles. Other read/write + -- Handles must share a buffer. + | ReadWriteHandle <- ha_type -> + mkDuplexHandle fd is_socket filepath binary + | otherwise -> + mkFileHandle fd is_socket filepath ha_type binary + + RawDevice -> + mkFileHandle fd is_socket filepath ha_type binary + _ -> ioException (IOError Nothing UnsupportedOperation "openFd" "unknown file type" Nothing) - where - mkIt ht - | isReadWriteHandleType ht = mkDuplexHandle fd is_socket filepath binary - | otherwise = mkFileHandle fd is_socket filepath ht binary fdToHandle :: FD -> IO Handle fdToHandle fd = do