public Method

Dir.seek(p1)

dir.seek( integer )  dir

Seeks to a particular location in dir. integer must be a value returned by Dir#tell.

d = Dir.new("testdir")   #=> #<dir:0x401b3c40>
d.read                   #=> "."
i = d.tell               #=> 12
d.read                   #=> ".."
d.seek(i)                #=> #<dir:0x401b3c40>
d.read                   #=> ".."</dir:0x401b3c40></dir:0x401b3c40>

Source Code

/*
*  call-seq:
*     dir.seek( integer ) => dir
*
*  Seeks to a particular location in <em>dir</em>. <i>integer</i>
*  must be a value returned by <code>Dir#tell</code>.
*
*     d = Dir.new("testdir")   #=> #<Dir:0x401b3c40>
*     d.read                   #=> "."
*     i = d.tell               #=> 12
*     d.read                   #=> ".."
*     d.seek(i)                #=> #<Dir:0x401b3c40>
*     d.read                   #=> ".."
*/
static VALUE
dir_seek(dir, pos)
   VALUE dir, pos;
{
   struct dir_data *dirp;
   off_t p = NUM2OFFT(pos);

   GetDIR(dir, dirp);
#ifdef HAVE_SEEKDIR
   seekdir(dirp->dir, p);
   return dir;
#else
   rb_notimplement();
#endif
}
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.