C (76/207)

From:Nicholas Clarke
Date:10 Dec 99 at 17:16:08
Subject:Re: FRead()/FWrite()

From: Nicholas Clarke <nclarke@diku.dk>

On Fri, 10 Dec 1999, David Arbuthnot wrote:

> From: David Arbuthnot <Trebor@Digital.Prestel.co.uk>
>
> Hello,
>
> but this won't work because if fread does not read a full block I have
> no easy way to find out how many bytes FRead actually read (unless I counted
> the buffer i store the data in, but this provides the problem of what
> character to use as meaning that there is no more data, i.e I can't test
> for 0x00 as the file being copied could be a binary file that contains
> 0x00's)
>
> I can't seem to find a way around this problem.

You could use the filesize and loop through all the full blocks and use a
seperate read for the last possibly incomplete block of data.

Even better you could use the seek function to determine how much was
read. A seek() should not add any overhead and would also handle the event
that the filehandler reads random amounts of data, though unlikely except
in case of EOF.

/ngc