static public Method

Dir.open(p1)

Dir.open( string )  aDir
Dir.open( string ) {| aDir | block }  anObject

With no block, open is a synonym for Dir::new. If a block is present, it is passed aDir as a parameter. The directory is closed at the end of the block, and Dir::open returns the value of the block.

Source Code

/*
*  call-seq:
*     Dir.open( string ) => aDir
*     Dir.open( string ) {| aDir | block } => anObject
*
*  With no block, <code>open</code> is a synonym for
*  <code>Dir::new</code>. If a block is present, it is passed
*  <i>aDir</i> as a parameter. The directory is closed at the end of
*  the block, and <code>Dir::open</code> returns the value of the
*  block.
*/

static VALUE
dir_s_open(klass, dirname)
   VALUE klass, dirname;
{
   struct dir_data *dp;
   VALUE dir = Data_Make_Struct(klass, struct dir_data, 0, free_dir, dp);

   dir_initialize(dir, dirname);
   if (rb_block_given_p()) {
       return rb_ensure(rb_yield, dir, dir_close, dir);
   }

   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.