Transient ranges

Steven Schveighoffer via Digitalmars-d digitalmars-d at puremagic.com
Wed Jun 1 17:38:11 PDT 2016


On 6/1/16 10:05 AM, Patrick Schluter wrote:
> On Tuesday, 31 May 2016 at 12:42:23 UTC, Steven Schveighoffer wrote:
>
>> There are 2 main issues with FILE *:
>>
>> 1) it does not provide buffer access, so you must rely on things like
>> getline if they exist. But these have their own problems (i.e. do not
>> support unicode, require C-malloc'd buffer)
>>
> You can cheat by using setvbuf() and imposing your own buffer to the
> FILE* routine. What and how the underlying implementation put in that
> buffer is of course not documented but not very difficult to guess (for
> example fseek()/fread() will always fill the buffer from 0 to the end
> (of buffer or file depending what come first).

But there is no mechanism to determine where the current file pointer is 
inside the buffer. One could use ftell vs. tell on the file descriptor, 
but that is going to perform quite poorly.

-Steve


More information about the Digitalmars-d mailing list