static public Method

Dir.new(p1)

Dir.new( string )  aDir

Returns a new directory object for the named directory.

Source Code

/*
*  call-seq:
*     Dir.new( string ) -> aDir
*
*  Returns a new directory object for the named directory.
*/
static VALUE
dir_initialize(dir, dirname)
   VALUE dir, dirname;
{
   struct dir_data *dp;

   SafeStringValue(dirname);
   Data_Get_Struct(dir, struct dir_data, dp);
   if (dp->dir) closedir(dp->dir);
   if (dp->path) free(dp->path);
   dp->dir = NULL;
   dp->path = NULL;
   dp->dir = opendir(RSTRING(dirname)->ptr);
   if (dp->dir == NULL) {
       if (errno == EMFILE || errno == ENFILE) {
           rb_gc();
           dp->dir = opendir(RSTRING(dirname)->ptr);
       }
       if (dp->dir == NULL) {
           rb_sys_fail(RSTRING(dirname)->ptr);
       }
   }
   dp->path = strdup(RSTRING(dirname)->ptr);

   return dir;
}
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.