public FileDescriptorIO(Ruby runtime, RubyClass klass) {
super(runtime, klass);
}
public FileDescriptorIO(Ruby runtime, IRubyObject fd) {
super(runtime, FFIProvider.getModule(runtime).fastGetClass(CLASS_NAME));
ModeFlags modes;
try {
modes = new ModeFlags(ModeFlags.RDWR);
} catch (InvalidValueException ex) {
throw new RuntimeException(ex);
}
openFile.setMainStream(new ChannelStream(getRuntime(),
new ChannelDescriptor(Factory.getInstance().newByteChannel(RubyNumeric.fix2int(fd)),
getNewFileno(), modes, new java.io.FileDescriptor())));
openFile.setPipeStream(openFile.getMainStream());
openFile.setMode(modes.getOpenFileFlags());
openFile.getMainStream().setSync(true);
}