Track current changes in the text-mode-seek-on-Windows saga.
# -----------------------------------------------------------------------------
-# $Id: Makefile,v 1.7 2001/06/01 14:33:01 sewardj Exp $
+# $Id: Makefile,v 1.8 2001/06/07 10:45:30 sewardj Exp $
TOP = ../..
include $(TOP)/mk/should_run.mk
-SRC_HC_OPTS += -dcore-lint
+SRC_HC_OPTS += -dcore-lint -cpp
hGetBuffering001_RUNTEST_OPTS += -i hGetBuffering001.hs
hSetBuffering002_RUNTEST_OPTS += -i hSetBuffering002.hs
hFileSize001_RUNTEST_OPTS += -o1 hFileSize001.stdout-mingw
hSeek004_RUNTEST_OPTS += -o1 hSeek004.stdout-mingw
hGetPosn001_RUNTEST_OPTS += -o1 hGetPosn001.stdout-mingw
+openFile003_RUNTEST_OPTS += -o1 openFile003.stdout-mingw
+openFile005_RUNTEST_OPTS += -o1 openFile005.stdout-mingw
.PRECIOUS: %.o %.bin
-- !!! testing hGetLine
import IO
+#if defined(__MINGW32__)
+import PrelHandle(hSetBinaryMode)
+#endif
-- one version of 'cat'
main = do
loop stdin
h <- openFile "hGetLine001.hs" ReadMode
+
+# if defined(__MINGW32__)
hSetBinaryMode h True
+# endif
hSetBuffering h NoBuffering
loop h
-- !!! testing hGetLine
import IO
+#if defined(__MINGW32__)
+import PrelHandle(hSetBinaryMode)
+#endif
-- one version of 'cat'
main = do
loop stdin
h <- openFile "hGetLine001.hs" ReadMode
+
+# if defined(__MINGW32__)
hSetBinaryMode h True
+# endif
hSetBuffering h NoBuffering
loop h
-- !!! testing hGetLine\r
\r
import IO\r
+#if defined(__MINGW32__)\r
+import PrelHandle(hSetBinaryMode)\r
+#endif\r
\r
-- one version of 'cat'\r
main = do\r
loop stdin \r
\r
h <- openFile "hGetLine001.hs" ReadMode\r
+\r
+# if defined(__MINGW32__)\r
hSetBinaryMode h True\r
+# endif\r
\r
hSetBuffering h NoBuffering\r
loop h\r
-- !!! testing hGetLine\r
\r
import IO\r
+#if defined(__MINGW32__)\r
+import PrelHandle(hSetBinaryMode)\r
+#endif\r
\r
-- one version of 'cat'\r
main = do\r
loop stdin \r
\r
h <- openFile "hGetLine001.hs" ReadMode\r
+\r
+# if defined(__MINGW32__)\r
hSetBinaryMode h True\r
+# endif\r
\r
hSetBuffering h NoBuffering\r
loop h\r
-- !!! testing hGetLine\r
\r
import IO\r
+#if defined(__MINGW32__)\r
+import PrelHandle(hSetBinaryMode)\r
+#endif\r
\r
-- one version of 'cat'\r
main = do\r
loop stdin \r
\r
h <- openFile "hGetLine001.hs" ReadMode\r
+\r
+# if defined(__MINGW32__)\r
hSetBinaryMode h True\r
+# endif\r
\r
hSetBuffering h NoBuffering\r
loop h\r
import IO
import Monad
-
import Directory (removeFile, doesFileExist)
+#if defined(__MINGW32__)
+import PrelHandle(hSetBinaryMode)
+#endif
main = do
hIn <- openFile "hGetPosn001.in" ReadMode
+# if defined(__MINGW32__)
hSetBinaryMode hIn True
+# endif
f <- doesFileExist "hGetPosn001.out"
when f (removeFile "hGetPosn001.out")
hOut <- openFile "hGetPosn001.out" ReadWriteMode
+# if defined(__MINGW32__)
hSetBinaryMode hOut True
+# endif
bof <- hGetPosn hIn
copy hIn hOut
hSetPosn bof
-- !!! test hIsEOF in various buffering situations
import IO
+#if defined(__MINGW32__)
+import PrelHandle(hSetBinaryMode)
+#endif
main = do
h <- openFile "hIsEOF002.hs" ReadMode
+# if defined(__MINGW32__)
hSetBinaryMode h True
+# endif
hSetBuffering h NoBuffering
hSeek h SeekFromEnd 0
hIsEOF h >>= print
hClose h
h <- openFile "hIsEOF002.out" ReadWriteMode
+# if defined(__MINGW32__)
hSetBinaryMode h True
+# endif
hSetBuffering h NoBuffering
hSeek h SeekFromEnd 0
hIsEOF h >>= print
-- but in GHC it returns True (known bug).
import IO
+#if defined(__MINGW32__)
+import PrelHandle(hSetBinaryMode)
+#endif
main = do
h <- openFile "hReady001.hs" ReadMode
+#if defined(__MINGW32__)
hSetBinaryMode h True
+#endif
hSeek h SeekFromEnd 0
hReady h >>= print
-- !!! Test seeking
import IO
+#if defined(__MINGW32__)
+import PrelHandle(hSetBinaryMode)
+#endif
main = do
h <- openFile "hSeek001.in" ReadMode
+# if defined(__MINGW32__)
hSetBinaryMode h True
+# endif
True <- hIsSeekable h
hSeek h SeekFromEnd (-1)
z <- hGetChar h
import IO
import Directory ( removeFile )
+#if defined(__MINGW32__)
+import PrelHandle(hSetBinaryMode)
+#endif
main :: IO ()
main = do
hdl <- openFile "hSeek002.hs" ReadMode
+# if defined(__MINGW32__)
hSetBinaryMode hdl True
+# endif
flg <- hIsEOF hdl
print flg
hSeek hdl SeekFromEnd 0
import IO
import Monad ( sequence )
+#if defined(__MINGW32__)
+import PrelHandle(hSetBinaryMode)
+#endif
testPosns :: Handle -> BufferMode -> IO ()
testPosns hdl bmo = do
main = do
hdl <- openFile "hSeek003.hs" ReadMode
+# if defined(__MINGW32__)
hSetBinaryMode hdl True
+# endif
sequence (zipWith testPosns (repeat hdl) bmo_ls)
hClose hdl
-- !!! can't seek an AppendMode handle
import IO
+#if defined(__MINGW32__)
+import PrelHandle(hSetBinaryMode)
+#endif
main = do
h <- openFile "hSeek004.out" AppendMode
+# if defined(__MINGW32__)
hSetBinaryMode h True
+# endif
try (hSeek h AbsoluteSeek 0) >>= print
import IO
import Maybe
+#if defined(__MINGW32__)
+import PrelHandle(hSetBinaryMode)
+#endif
main = do
h <- openFile "ioeGetErrorString001.hs" ReadMode
+# if defined(__MINGW32__)
hSetBinaryMode h True
+# endif
hSeek h SeekFromEnd 0
(hGetChar h >> return ()) `catch`
\e -> if isEOFError e
-- !!! test ioeGetFileName
import IO
+#if defined(__MINGW32__)
+import PrelHandle(hSetBinaryMode)
+#endif
main = do
h <- openFile "ioeGetFileName001.hs" ReadMode
+# if defined(__MINGW32__)
hSetBinaryMode h True
+# endif
hSeek h SeekFromEnd 0
(hGetChar h >> return ()) `catch`
\e -> if isEOFError e
import IO
import Maybe
+#if defined(__MINGW32__)
+import PrelHandle(hSetBinaryMode)
+#endif
main = do
h <- openFile "ioeGetHandle001.hs" ReadMode
+# if defined(__MINGW32__)
hSetBinaryMode h True
+# endif
hSeek h SeekFromEnd 0
(hGetChar h >> return ()) `catch`
\e -> if isEOFError e && fromJust (ioeGetHandle e) == h
--- /dev/null
+Left permission denied
+Action: openFile
+Reason: Permission denied
+File: .
+Left permission denied
+Action: openFile
+Reason: Permission denied
+File: .
+Left permission denied
+Action: openFile
+Reason: Permission denied
+File: .
+Left permission denied
+Action: openFile
+Reason: Permission denied
+File: .
--- /dev/null
+two writes (should fail)
+Right {loc=openFile005.out1,type=writable,binary=False,buffering=block (512)}
+write and an append (should fail)
+Right {loc=openFile005.out1,type=writable (append),binary=False,buffering=block (512)}
+read/write and a write (should fail)
+Right {loc=openFile005.out1,type=writable,binary=False,buffering=block (512)}
+read and a read/write (should fail)
+Right {loc=openFile005.out1,type=read-writable,binary=False,buffering=block (512)}
+write and a read (should fail)
+Right {loc=openFile005.out1,type=readable,binary=False,buffering=block (512)}
+two writes, different files (silly, but should succeed)
+two reads, should succeed
import IO
import Directory ( removeFile, doesFileExist )
import Monad
+#if defined(__MINGW32__)
+import PrelHandle(hSetBinaryMode)
+#endif
main = do
f <- doesFileExist "readwrite001.inout"
when f (removeFile "readwrite001.inout")
hdl <- openFile "readwrite001.inout" ReadWriteMode
+# if defined(__MINGW32__)
hSetBinaryMode hdl True
+# endif
hSetBuffering hdl LineBuffering
hPutStr hdl "as"
hSeek hdl AbsoluteSeek 0
import IO
import Directory (removeFile, doesFileExist)
import Monad
+#if defined(__MINGW32__)
+import PrelHandle(hSetBinaryMode)
+#endif
-- This test is weird, full marks to whoever dreamt it up!
f <- doesFileExist username
when f (removeFile username)
cd <- openFile username ReadWriteMode
+# if defined(__MINGW32__)
hSetBinaryMode cd True
+# endif
hSetBuffering stdin NoBuffering
hSetBuffering stdout NoBuffering
hSetBuffering cd NoBuffering