public Method

Dir.rewind

dir.rewind  dir

Repositions dir to the first entry.

d = Dir.new("testdir")
d.read     #=> "."
d.rewind   #=> #<dir:0x401b3fb0>
d.read     #=> "."</dir:0x401b3fb0>

Source Code

/*
*  call-seq:
*     dir.rewind => dir
*
*  Repositions <em>dir</em> to the first entry.
*
*     d = Dir.new("testdir")
*     d.read     #=> "."
*     d.rewind   #=> #<Dir:0x401b3fb0>
*     d.read     #=> "."
*/
static VALUE
dir_rewind(dir)
   VALUE dir;
{
   struct dir_data *dirp;

   if (rb_safe_level() >= 4 && !OBJ_TAINTED(dir)) {
       rb_raise(rb_eSecurityError, "Insecure: can't close");
   }
   GetDIR(dir, dirp);
   rewinddir(dirp->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.