Guest User

Untitled

a guest
Jan 22nd, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. static VALUE
  2. rb_io_seek_m(int argc, VALUE *argv, VALUE io)
  3. {
  4. VALUE offset, ptrname;
  5. int whence = SEEK_SET;
  6.  
  7. if (rb_scan_args(argc, argv, "11", &offset, &ptrname) == 2) {
  8. whence = NUM2INT(ptrname);
  9. }
  10.  
  11. return rb_io_seek(io, offset, whence);
  12. }
  13.  
  14. // and for rb_io_seek
  15.  
  16. static VALUE
  17. rb_io_seek(VALUE io, VALUE offset, int whence)
  18. {
  19. rb_io_t *fptr;
  20. off_t pos;
  21.  
  22. pos = NUM2OFFT(offset);
  23. GetOpenFile(io, fptr);
  24. pos = io_seek(fptr, pos, whence);
  25. if (pos < 0 && errno) rb_sys_fail_path(fptr->pathv);
  26.  
  27. return INT2FIX(0);
  28. }
Add Comment
Please, Sign In to add comment