static public Method

File.blockdev?(p1)

File.blockdev?(file_name)     true or false

Returns true if the named file is a block device.

Source Code

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

static VALUE
test_b(obj, fname)
   VALUE obj, fname;
{
#ifndef S_ISBLK
#   ifdef S_IFBLK
#       define S_ISBLK(m) ((m & S_IFMT) == S_IFBLK)
#   else
#       define S_ISBLK(m) (0)  /* anytime false */
#   endif
#endif

#ifdef S_ISBLK
   struct stat st;

   if (rb_stat(fname, &st) < 0) return Qfalse;
   if (S_ISBLK(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.