chardev?(p1)
public
Returns true if the named file is a character device.
Show source
/*
* call-seq:
* File.chardev?(file_name) => true or false
*
* Returns <code>true</code> if the named file is a character device.
*/
static VALUE
test_c(obj, fname)
VALUE obj, fname;
{
#ifndef S_ISCHR
# define S_ISCHR(m) ((m & S_IFMT) == S_IFCHR)
#endif
struct stat st;
if (rb_stat(fname, &st) < 0) return Qfalse;
if (S_ISCHR(st.st_mode)) return Qtrue;
return Qfalse;
}