logo       

[GHC] #679: using ReadWriteMode in Windows corrupts files: msg#00187

lang.haskell.glasgow.bugs

Subject: [GHC] #679: using ReadWriteMode in Windows corrupts files

#679: using ReadWriteMode in Windows corrupts files
-------------------------------+--------------------------------------------
Reporter: aljee@xxxxxxxx | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: libraries/base | Version: 6.4.1
Severity: normal | Keywords:
Os: Windows | Difficulty: Unknown
Architecture: Unknown |
-------------------------------+--------------------------------------------
In Windows, running the following program makes test.txt corrupted.
{{{
import System.IO
main = do
h <- openFile "test.txt" ReadWriteMode
hGetLine h
hPutStrLn h "yz"
hClose h
}}}
Initial content of test.txt is:
{{{
ab
cd
ef
gh
}}}
Expected content of test.txt after the excution is:
{{{
ab
yz
ef
gh
}}}
Actual result is(in hex):

61 62 0d 0a 63 64 0d 79 7a 0d 0a 0a 67 68 0d 0a

I think that the problem is that GHC.Handle.flushReadBuffer does not
calculate the correct amount of seek to be done.

--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/679>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler_______________________________________________
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@xxxxxxxxxxx
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise