ioException (IOError Nothing InappropriateType "openFile"
"is a directory" Nothing)
- Stream
- | ReadWriteHandle <- ha_type -> mkDuplexHandle fd is_socket filepath binary
- | otherwise -> mkFileHandle fd is_socket filepath ha_type binary
-
-- regular files need to be locked
RegularFile -> do
#ifndef mingw32_HOST_OS
"file is locked" Nothing)
#endif
mkFileHandle fd is_socket filepath ha_type binary
-
+ -- Stream or RawDevice
+ Stream -> mkIt ha_type
+ RawDevice -> mkIt ha_type
+ _ ->
+ 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
-- fill up the read buffer if necessary
new_buf <- if bufferEmpty buf
- then fillReadBuffer fd is_line (haIsStream handle_) buf
+ then fillReadBuffer fd True (haIsStream handle_) buf
else return buf
writeIORef ref new_buf
SemiClosedHandle -> ioe_closedHandle
AppendHandle -> return False
_ -> do t <- fdType (haFD handle_)
- return (t == RegularFile
- && (haIsBin handle_
- || tEXT_MODE_SEEK_ALLOWED))
+ return ((t == RegularFile || t == RawDevice)
+ && (haIsBin handle_ || tEXT_MODE_SEEK_ALLOWED))
-- -----------------------------------------------------------------------------
-- Changing echo status (Non-standard GHC extensions)