Method: File.directory?
- Defined in:
- file.c
.directory?(fname) ⇒ Boolean
call-seq:
File.directory?(file_name) -> true or false
Returns true
if the named file is a directory, or a symlink that points at a directory, and false
otherwise.
file_name can be an IO object.
File.directory?(".")
1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 |
# File 'file.c', line 1576
VALUE
rb_file_directory_p(VALUE obj, VALUE fname)
{
#ifndef S_ISDIR
# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
#endif
struct stat st;
if (rb_stat(fname, &st) < 0) return Qfalse;
if (S_ISDIR(st.st_mode)) return Qtrue;
return Qfalse;
}
|