> -----Original Message-----
> From: Paul Brannan [mailto:pbrannan / atdesk.com] 
> Sent: Wednesday, January 05, 2005 8:53 AM
> To: ruby-core / ruby-lang.org
> Subject: Re: [BUG] Win32: rb_sys_fail() - errno == 0
> 
> 
> On Thu, Jan 06, 2005 at 12:34:27AM +0900, Berger, Daniel wrote:
> > I'm not sure I follow, because this has worked as expected 
> in certain 
> > circumstances in the past (i.e. it raised Errno::ENOENT).
> > 
> > Perhaps I need more detail on how rb_sys_fail() actually works.
> 
> Perhaps you need an abstraction like this one (from
> http://www.cs.wustl.edu/~schmidt/ACE_wrappers/ace/OS_NS_errno.inl):
> 
>   ACE_INLINE int
>   ACE_OS::last_error (void)
>   {
>     // ACE_OS_TRACE ("ACE_OS::last_error");
> 
>   #if defined (ACE_WIN32)
>     // ACE_OS::last_error() prefers errnor since started out 
> as a way to
>     // avoid directly accessing errno in ACE code - 
> particularly the ACE
>     // C++ socket wrapper facades.  On Windows, some things that would
>     // use errno on UNIX require ::GetLastError(), so this 
> method tries
>     // to shield the rest of ACE from having to know about this.
>     int lerror = ::GetLastError ();
>     int lerrno = errno;
>     return lerrno == 0 ? lerror : lerrno;
>   #else
>     return errno;
>   #endif /* ACE_WIN32 */
> 
> Or perhaps rb_sys_fail() should do this behind the scenes.

Thanks for this Paul - I'll take a look.
 
> > That, or I need to figure out a way to explicitly raise 
> Errno::ENOENT 
> > within a C extension.
> 
> The easiest way is to set errno to ENOENT before calling 
> rb_sys_fail().

Actually, I couldn't figure out how to do that.  Or is errno an external
int that I can just set without having to declare?

Regards,

Dan