return context.getRuntime().newFixnum(pos);
}
@JRubyMethod(name = "rewind")
public RubyFixnum rewind(ThreadContext context) {
OpenFile myOpenfile = getOpenFileChecked();
try {
myOpenfile.getMainStream().lseek(0L, Stream.SEEK_SET);
myOpenfile.getMainStream().clearerr();
// TODO: This is some goofy global file value from MRI..what to do?
// if (io == current_file) {
// gets_lineno -= fptr->lineno;
// }
} catch (BadDescriptorException e) {
throw context.getRuntime().newErrnoEBADFError();
} catch (InvalidValueException e) {
throw context.getRuntime().newErrnoEINVALError();
} catch (PipeException e) {
throw context.getRuntime().newErrnoESPIPEError();
} catch (IOException e) {
throw context.getRuntime().newIOError(e.getMessage());
}
// Must be back on first line on rewind.
myOpenfile.setLineNumber(0);
return RubyFixnum.zero(context.getRuntime());
}