hSeek on text files
simonmarhaskell at gmail.com
Fri Jul 28 09:37:29 EDT 2006
Bulat Ziganshin wrote:
> Simon, are you remember problem with using hTell+hSeek on handles open
> in text (not binary) mode on Windows? afair, you was finished with the
> decision to use NoBuffering for text files on Windows?
Not quite - buffering is still used on text files, *unless* the file is opened
in ReadWriteMode, in which case we force the buffering to NoBuffering. This is
because when used with buffering, ReadWriteMode may need to seek internally.
I believe hTell/hSeek will work properly on an output file (hTell forces a flush
on Windows). They probably don't work properly with a ReadMode text file.
> but this solution is very inefficient. i now thought about dealing
> with the same problem in my lib and found that there is another
> solution - prohibit using of hTell/hSeek on files open in text mode
> (on Unix, too?). i think this is better - one should either open file
> in binary mode and use random access or open file in text mode and
> read/write it sequentially. what you think about it?
> also, i will be glad to hear comments from other haskellers
The single combination of (hTell + buffering + read mode + text translation)
should be disallowed, but I think all other variants can be supported.
More information about the Libraries