using ReadWriteMode in Windows corrupts files
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.
Trac metadata
Trac field | Value |
---|---|
Version | 6.4.1 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | libraries/base |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture | Unknown |