apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeff Trawick <traw...@attglobal.net>
Subject Re: apr file questions
Date Thu, 18 Apr 2002 14:06:16 GMT
Stas Bekman <stas@stason.org> writes:

> 2. What's the idiomatic apr read till eof? From grepping the source
> code, I see apr_file_eof is hardly ever used. Is something wrong with:
> 
>          while (!apr_file_eof(fp)) {
>              rc = apr_file_read(fp, buf, &nbytes);
>              ...
>          }
> 
> I saw code like this:
> 
>          while (apr_file_read(file, buffer, &len) != APR_SUCCESS)
>          {
>             ...
>          }
> 
> which one is better to use?

I would suggest the second one.  What if you hit an I/O error?  I
always did

  while (!feof() && !ferror())

with stdio.

-- 
Jeff Trawick | trawick@attglobal.net
Born in Roswell... married an alien...

Mime
View raw message