-\begin{code}
-hPutFS :: Handle -> FastString -> IO ()
-#if __GLASGOW_HASKELL__ <= 302
-hPutFS handle (FastString _ l# ba#) =
- if l# ==# 0# then
- return ()
- else
- readHandle handle >>= \ htype ->
- case htype of
- ErrorHandle ioError ->
- writeHandle handle htype >>
- fail ioError
- ClosedHandle ->
- writeHandle handle htype >>
- fail MkIOError(handle,IllegalOperation,"handle is closed")
- SemiClosedHandle _ _ ->
- writeHandle handle htype >>
- fail MkIOError(handle,IllegalOperation,"handle is closed")
- ReadHandle _ _ _ ->
- writeHandle handle htype >>
- fail MkIOError(handle,IllegalOperation,"handle is not open for writing")
- other ->
- let fp = filePtr htype in
- -- here we go..
- _ccall_ writeFile (ByteArray ((error "")::(Int,Int)) ba#) fp (I# l#) >>= \rc ->
- if rc==0 then
- return ()
- else
- constructError "hPutFS" >>= \ err ->
- fail err
-hPutFS handle (CharStr a# l#) =
- if l# ==# 0# then
- return ()
- else
- readHandle handle >>= \ htype ->
- case htype of
- ErrorHandle ioError ->
- writeHandle handle htype >>
- fail ioError
- ClosedHandle ->
- writeHandle handle htype >>
- fail MkIOError(handle,IllegalOperation,"handle is closed")
- SemiClosedHandle _ _ ->
- writeHandle handle htype >>
- fail MkIOError(handle,IllegalOperation,"handle is closed")
- ReadHandle _ _ _ ->
- writeHandle handle htype >>
- fail MkIOError(handle,IllegalOperation,"handle is not open for writing")
- other ->
- let fp = filePtr htype in
- -- here we go..
- _ccall_ writeFile (A# a#) fp (I# l#) >>= \rc ->
- if rc==0 then
- return ()
- else
- constructError "hPutFS" >>= \ err ->
- fail err
-#else