public void checkWritable(Ruby runtime) throws IOException, BadDescriptorException, InvalidValueException { checkClosed(runtime); if ((mode & WRITABLE) == 0) { throw runtime.newIOError("not opened for writing"); } if ((mode & RBUF) != 0 && !mainStream.feof() && pipeStream == null) { try { // seek to force read buffer to invalidate seek(0, Stream.SEEK_CUR); } catch (PipeException p) { // ignore unseekable streams for purposes of checking readability } catch (IOException ioe) { // MRI ignores seek errors, presumably for unseekable files like // serial ports (JRUBY-2979), so we shall too. } } if (pipeStream == null) { mode &= ~RBUF; } }
public void checkReadable(Ruby runtime) throws IOException, BadDescriptorException, InvalidValueException { checkClosed(runtime); if ((mode & READABLE) == 0) { throw runtime.newIOError("not opened for reading"); } if (((mode & WBUF) != 0 || (mode & (SYNCWRITE | RBUF)) == SYNCWRITE) && !mainStream.feof() && pipeStream == null) { try { // seek to force underlying buffer to flush seek(0, Stream.SEEK_CUR); } catch (PipeException p) { // ignore unseekable streams for purposes of checking readability } catch (IOException ioe) { // MRI ignores seek errors, presumably for unseekable files like // serial ports (JRUBY-2979), so we shall too. } } }
public boolean areBothEOF() throws IOException, BadDescriptorException { return mainStream.feof() && (pipeStream != null ? pipeStream.feof() : true); }