instance method
FileTest#blockdev?
(::path | ::io file_name) -> bool
File.blockdev?(filepath) → true or false
file.c
View on GitHub ↗
static VALUE
rb_file_blockdev_p(VALUE obj, VALUE 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;
}
Returns true if filepath points to a block device, false otherwise:
Example
File.blockdev?('/dev/sda1') # => true File.blockdev?(File.new('t.tmp')) # => false