Alain Ketterlin <> writes:
> Keith Thompson <kst-> writes:
>> Alain Ketterlin <> writes:
>>> felix <> writes:
>>>> if ( stat ( logFile, &results ) == 0 )
>>>
>>> Use ftell() instead (or lseek() at level 2).
>>
>> What makes you think that will yield better results,
>
> What makes you think it will not. At least ftell() is C.
We know that stat() isn't working as the OP expects. I'd expect
ftell() to yield exactly the same results -- and it requires opening
the file and seeking to the end of it. Furthermore, there's no
guarantee in C that the fseek()/ftell() trick will accurately yield
the size of a file. Binary streams may legally be padded with an
implementation-defined number of null characters (N1370 7.21.2p3),
and "A binary stream need not meaningfully support fseek calls
with a whence value of SEEK_END" (7.21.9.2p3). For text streams,
the value returned by ftell() isn't necessarily meaningful except
as an argument to fseek() (7.21.9.4p2).
A POSIX environment makes more guarantees -- but as long as you're
depending on POSIX, there's no good reason not to use stat()
(or fstat() or lstat()).
My point is that you suggested ftell() as a solution to the OP's
problem. It isn't.
>> and what is "level 2"?
>
> Unixism. Just ignore it if it hurts you.
If you're referring to section 2 of the manual (ftell(2),
documentation available via "man 2 ftell"), I've never heard of
that being referred to as "level 2". Try being a little less
condescending and actually answering the question.
--
Keith Thompson (The_Other_Keith)
kst- <http://www.ghoti.net/~kst>
Will write code for food.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"