private static RubyIO getRubyIO(Ruby runtime, Writer writer) throws IOException, BadDescriptorException { PrintStream pstream = new PrintStream(new WriterOutputStream(writer), true); RubyIO io = new RubyIO(runtime, pstream, false); io.getOpenFile().getMainStreamSafe().setSync(true); io.getOpenFile().getMainStreamSafe().fflush(); return io; }
private static RubyIO getRubyIO(Ruby runtime, Writer writer) throws IOException, BadDescriptorException { PrintStream pstream = new PrintStream(new WriterOutputStream(writer), true); RubyIO io = new RubyIO(runtime, pstream, false); io.getOpenFile().getMainStreamSafe().setSync(true); io.getOpenFile().getMainStreamSafe().fflush(); return io; }
public boolean getBlocking() { try { return ((ChannelStream) openFile.getMainStreamSafe()).isBlocking(); } catch (BadDescriptorException e) { throw getRuntime().newErrnoEBADFError(); } }
public boolean getBlocking() { try { return ((ChannelStream) openFile.getMainStreamSafe()).isBlocking(); } catch (BadDescriptorException e) { throw getRuntime().newErrnoEBADFError(); } }
private void saveBufferedRead(RubyIO ioObj, int i) throws BadDescriptorException { // already buffered data? don't bother selecting if (ioObj.getOpenFile().getMainStreamSafe().readDataBuffered()) { getUnselectableReads()[i] = true; } }
private void saveBufferedRead(RubyIO ioObj, int i) throws BadDescriptorException { // already buffered data? don't bother selecting if (ioObj.getOpenFile().getMainStreamSafe().readDataBuffered()) { getUnselectableReads()[i] = true; } }
public OutputStream getOutStream() { try { return getOpenFileChecked().getMainStreamSafe().newOutputStream(); } catch (BadDescriptorException e) { throw getRuntime().newErrnoEBADFError(); } }
public InputStream getInStream() { try { return getOpenFileChecked().getMainStreamSafe().newInputStream(); } catch (BadDescriptorException e) { throw getRuntime().newErrnoEBADFError(); } }
public Channel getChannel() { try { return getOpenFileChecked().getMainStreamSafe().getChannel(); } catch (BadDescriptorException e) { throw getRuntime().newErrnoEBADFError(); } }
protected void init_sock(Ruby runtime) { try { ModeFlags modes = newModeFlags(runtime, ModeFlags.RDWR); MakeOpenFile(); openFile.setMainStream(ChannelStream.open(runtime, new ChannelDescriptor(channel, modes))); openFile.setPipeStream(openFile.getMainStreamSafe()); openFile.setMode(modes.getOpenFileFlags()); openFile.getMainStreamSafe().setSync(true); } catch (BadDescriptorException e) { throw runtime.newErrnoEBADFError(); } }
/** Returns the current sync mode. * * @return the current sync mode. */ @JRubyMethod(name = "sync") public RubyBoolean sync(ThreadContext context) { try { return context.runtime.newBoolean(getOpenFileChecked().getMainStreamSafe().isSync()); } catch (BadDescriptorException e) { throw context.runtime.newErrnoEBADFError(); } }
/** Returns the current sync mode. * * @return the current sync mode. */ @JRubyMethod(name = "sync") public RubyBoolean sync(ThreadContext context) { try { return context.runtime.newBoolean(getOpenFileChecked().getMainStreamSafe().isSync()); } catch (BadDescriptorException e) { throw context.runtime.newErrnoEBADFError(); } }
@Override public String toString() { try { return "RubyIO(" + openFile.getMode() + ", " + getRuntime().getFileno(openFile.getMainStreamSafe().getDescriptor()) + ")"; } catch (BadDescriptorException e) { throw getRuntime().newErrnoEBADFError(); } }
@JRubyMethod(name = "fileno", alias = "to_i") public RubyFixnum fileno(ThreadContext context) { Ruby runtime = context.runtime; // map to external fileno try { return runtime.newFixnum(runtime.getFileno(getOpenFileChecked().getMainStreamSafe().getDescriptor())); } catch (BadDescriptorException e) { throw runtime.newErrnoEBADFError(); } }
@JRubyMethod(name = "fileno", alias = "to_i") public RubyFixnum fileno(ThreadContext context) { Ruby runtime = context.runtime; // map to external fileno try { return runtime.newFixnum(runtime.getFileno(getOpenFileChecked().getMainStreamSafe().getDescriptor())); } catch (BadDescriptorException e) { throw runtime.newErrnoEBADFError(); } }
@Override public String toString() { try { return "RubyFile(" + path + ", " + openFile.getMode() + ", " + getRuntime().getFileno(openFile.getMainStreamSafe().getDescriptor()) + ")"; } catch (BadDescriptorException e) { throw getRuntime().newErrnoEBADFError(); } }
@JRubyMethod public IRubyObject stat(ThreadContext context) { openFile.checkClosed(context.runtime); try { return context.runtime.newFileStat(getOpenFileChecked().getMainStreamSafe().getDescriptor().getFileDescriptor()); } catch (BadDescriptorException e) { throw context.runtime.newErrnoEBADFError(); } }
@JRubyMethod public IRubyObject stat(ThreadContext context) { openFile.checkClosed(context.runtime); try { return context.runtime.newFileStat(getOpenFileChecked().getMainStreamSafe().getDescriptor().getFileDescriptor()); } catch (BadDescriptorException e) { throw context.runtime.newErrnoEBADFError(); } }
@JRubyMethod(name = {"tty?", "isatty"}) public RubyBoolean tty_p(ThreadContext context) { try { return context.runtime.newBoolean( context.runtime.getPosix().isatty( getOpenFileChecked().getMainStreamSafe().getDescriptor().getFileDescriptor())); } catch (BadDescriptorException e) { throw context.runtime.newErrnoEBADFError(); } }
@JRubyMethod(name = {"tty?", "isatty"}) public RubyBoolean tty_p(ThreadContext context) { try { return context.runtime.newBoolean( context.runtime.getPosix().isatty( getOpenFileChecked().getMainStreamSafe().getDescriptor().getFileDescriptor())); } catch (BadDescriptorException e) { throw context.runtime.newErrnoEBADFError(); } }