static public Method

File.directory?(p1)

File.directory?(file_name)     true or false

Returns true if the named file is a directory, false otherwise.

File.directory?(".")

Source Code

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

static VALUE
test_d(obj, fname)
   VALUE obj, 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;
}
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.