help-gawk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: readdir extension on windows with getline


From: Andrew J. Schorr
Subject: Re: readdir extension on windows with getline
Date: Thu, 26 Jan 2023 16:46:20 -0500
User-agent: Mutt/1.5.21 (2010-09-15)

On Thu, Jan 26, 2023 at 10:50:19PM +0200, Eli Zaretskii wrote:
> You assume that iobuf->fd is necessarily INVALID_HANDLE when we get to
> dir_can_take_file?  But if we disregard the failure to open and call
> iop_alloc anyway, then it does this:
> 
>       if (fd != INVALID_HANDLE)
>               fstat(fd, & iop->public.sbuf);
> #if defined(__MINGW32__)
>       else if (errno_val == EISDIR) {
>               iop->public.sbuf.st_mode = (_S_IFDIR | _S_IRWXU);
>               iop->public.fd = FAKE_FD_VALUE;  <<<<<<<<<<<<<<<<<<<
>       }
> #endif
> 
> And FAKE_FD_VALUE just _happens_ to be the "descriptor" that dirfd in
> readdir.c returns, see gawkdirfd.h.

Ah. Oops. That's what I get for having been too lazy to read
iop_alloc. It didn't occur tome that it could engage in such
skulduggery. Thanks for pointing this out.

> This is why readdir works for the command-line arguments: we don't
> try to open the file and bail out immediately when we fail.

Now I understand. Thanks for the additional explanation.

Regards,
Andy



reply via email to

[Prev in Thread] Current Thread [Next in Thread]