
On Fri, 2006-07-28 at 15:10 +0400, Bulat Ziganshin wrote:
after writing this letter, i added one more comment to my internal documentation - "hRewind and seeking to EOF will be also useful". about fseek - i don't see an easy way to implement it. if your translated data are already in buffer, then fseek can't return just file position corresponding to buffer start + current offset in buffer. btw, the same problem arises when we want to use UTF-8 or some other Char<->Byte translation with buffered I/O (using iconv, f.e.)
so, for translated text
1) we can implement hRewind/hSeekToEOF 2) we can implement some form of hSavePosition/hRestorePosition if this position will include tuple (file position of buffer start, offset in buffer) 3) we can implement tell/seek functionality but this will be slow
How about an inefficient seek that just does a linear scan from the beginning of the file counting translated characters? Then the odd case of seek on a text file is penalised rather than doing no buffering on text files which penalises the normal case. Duncan