/** * Check whether the isOpen returns true, raising a BadDescriptorException if * it returns false. * * @throws org.jruby.util.io.BadDescriptorException if isOpen returns false */ public void checkOpen() throws BadDescriptorException { if (!isOpen()) { throw new BadDescriptorException(); } }
/** * Check whether the isOpen returns true, raising a BadDescriptorException if * it returns false. * * @throws org.jruby.util.io.BadDescriptorException if isOpen returns false */ public void checkOpen() throws BadDescriptorException { if (!isOpen()) { throw new BadDescriptorException(); } }
/** * Check whether the isOpen returns true, raising a BadDescriptorException if * it returns false. * * @throws org.jruby.util.io.BadDescriptorException if isOpen returns false */ public void checkOpen() throws BadDescriptorException { if (!isOpen()) { throw new BadDescriptorException(); } }
/** * Check whether the isOpen returns true, raising a BadDescriptorException if * it returns false. * * @throws org.jruby.util.io.BadDescriptorException if isOpen returns false */ public void checkOpen() throws BadDescriptorException { if (!isOpen()) { throw new BadDescriptorException(); } }
/** * Ensure close (especially flush) when we're finished with. */ @Override public void finalize() throws Throwable { super.finalize(); if (closedExplicitly) return; if (DEBUG) { LOG.info("finalize() for not explicitly closed stream"); } // FIXME: I got a bunch of NPEs when I didn't check for nulls here...HOW?! if (descriptor != null && descriptor.isOpen()) { // tidy up finish(autoclose); } }
/** * Ensure close (especially flush) when we're finished with. */ @Override public void finalize() throws Throwable { super.finalize(); if (closedExplicitly) return; if (DEBUG) { LOG.info("finalize() for not explicitly closed stream"); } // FIXME: I got a bunch of NPEs when I didn't check for nulls here...HOW?! if (descriptor != null && descriptor.isOpen()) { // tidy up finish(autoclose); } }
/** * Ensure close (especially flush) when we're finished with. */ @Override public void finalize() throws Throwable { super.finalize(); if (closedExplicitly) return; if (DEBUG) { LOG.info("finalize() for not explicitly closed stream"); } // FIXME: I got a bunch of NPEs when I didn't check for nulls here...HOW?! if (descriptor != null && descriptor.isOpen()) { // tidy up finish(autoclose); } }
/** * Ensure close (especially flush) when we're finished with. */ @Override public void finalize() throws Throwable { super.finalize(); if (closedExplicitly) return; if (DEBUG) { LOG.info("finalize() for not explicitly closed stream"); } // FIXME: I got a bunch of NPEs when I didn't check for nulls here...HOW?! if (descriptor != null && descriptor.isOpen()) { // tidy up finish(autoclose); } }
if (descriptor.isOpen()) { descriptor.close();
if (descriptor.isOpen()) { descriptor.close();
if (descriptor.isOpen()) { descriptor.close();
if (descriptor.isOpen()) { descriptor.close();
/** * returns non-nil if input available without blocking, false if EOF or not open/readable, otherwise nil. */ @JRubyMethod(name = "ready?") public static IRubyObject ready(ThreadContext context, IRubyObject obj) { RubyIO io = (RubyIO)obj; try { OpenFile openFile = io.getOpenFile(); ChannelDescriptor descriptor = openFile.getMainStreamSafe().getDescriptor(); if (!descriptor.isOpen() || !openFile.getMainStreamSafe().getModes().isReadable() || openFile.getMainStreamSafe().feof()) { return context.runtime.getFalse(); } int avail = openFile.getMainStreamSafe().ready(); if (avail > 0) { return context.runtime.newFixnum(avail); } } catch (BadDescriptorException e) { throw context.runtime.newErrnoEBADFError(); } catch (Exception anyEx) { return context.runtime.getFalse(); } return context.runtime.getNil(); }
/** * returns non-nil if input available without blocking, false if EOF or not open/readable, otherwise nil. */ @JRubyMethod(name = "ready?") public static IRubyObject ready(ThreadContext context, IRubyObject obj) { RubyIO io = (RubyIO)obj; try { OpenFile openFile = io.getOpenFile(); ChannelDescriptor descriptor = openFile.getMainStreamSafe().getDescriptor(); if (!descriptor.isOpen() || !openFile.getMainStreamSafe().getModes().isReadable() || openFile.getMainStreamSafe().feof()) { return context.runtime.getFalse(); } int avail = openFile.getMainStreamSafe().ready(); if (avail > 0) { return context.runtime.newFixnum(avail); } } catch (BadDescriptorException e) { throw context.runtime.newErrnoEBADFError(); } catch (Exception anyEx) { return context.runtime.getFalse(); } return context.runtime.getNil(); }