Stas Bekman <[EMAIL PROTECTED]> writes:
> Jeff Trawick wrote:
> > Stas Bekman <[EMAIL PROTECTED]> 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?
>
> That's what rc = apr_file_read() is for, the following line with
> ... is for error checking.
>
> > I
> > always did
> >
> > while (!feof() && !ferror())
> >
> > with stdio.
>
> If you use a second or your example and have an IO error, this code
> won't be able to tell eof from an error, and simply move on. Is this
> good?
obviously you would save the apr_status_t :)
--
Jeff Trawick | [EMAIL PROTECTED]
Born in Roswell... married an alien...