static public Method

File.socket?(p1)

File.socket?(file_name)     true or false

Returns true if the named file is a socket.

Source Code

/*
* call-seq:
*   File.socket?(file_name)   =>  true or false
*
* Returns <code>true</code> if the named file is a socket.
*/

static VALUE
test_S(obj, fname)
   VALUE obj, fname;
{
#ifndef S_ISSOCK
#  ifdef _S_ISSOCK
#    define S_ISSOCK(m) _S_ISSOCK(m)
#  elif defined __BORLANDC__
#    ifdef _S_IFSOCK
#      define S_ISSOCK(m) (((unsigned short)(m) & S_IFMT) == _S_IFSOCK)
#    else
#      ifdef S_IFSOCK
#        define S_ISSOCK(m) (((unsigned short)(m) & S_IFMT) == S_IFSOCK)
#      endif
#    endif
#  else
#    ifdef _S_IFSOCK
#      define S_ISSOCK(m) ((m & S_IFMT) == _S_IFSOCK)
#    else
#      ifdef S_IFSOCK
#        define S_ISSOCK(m) ((m & S_IFMT) == S_IFSOCK)
#      endif
#    endif
#  endif
#endif

#ifdef S_ISSOCK
   struct stat st;

   if (rb_stat(fname, &st) < 0) return Qfalse;
   if (S_ISSOCK(st.st_mode)) return Qtrue;

#endif
   return Qfalse;
}
Comments

Have your say
Please use Textile formatting (click here for a cheat sheet). Use <code/> and <pre/> for code samples.
Click here to login with OpenID to to post comments.