Darrin Chandler <[EMAIL PROTECTED]> wrote:

> On Thu, Jan 18, 2007 at 05:17:50PM -0500, Adam wrote:
> > Why does fopen()ing a directory for reading succeed instead of failing
> > with EISDIR?  This has the possibly unexpected consequence of letting
> > you pass yyin to yylex() as a fopen()ed directory, which then thinks it
> > finished successfully because fread() returns 0 immediately.
> 
> Directories are files and can be open(2)ed as such for reading.

We're not talking about the low level open() interface, we're talking
about the abstracted fopen() wrapper.  You can't use fread() on a
fopen()ed directory, and when passed a FILE * you can't tell wether its
a directory or just an empty file.  If you can't fread() from a stream
that is associated with a directory, then why associate the stream with
a directory in the first place?

Adam

Reply via email to