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?
Thanks Jeff __________________________________________________________________ Stas Bekman JAm_pH ------> Just Another mod_perl Hacker http://stason.org/ mod_perl Guide ---> http://perl.apache.org mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com http://modperlbook.org http://apache.org http://ticketmaster.com