public void checkReadable() throws IOException { if (!modes.isReadable()) throw new IOException("not opened for reading"); }
public void checkReadable() throws IOException { if (!modes.isReadable()) throw new IOException("not opened for reading"); }
public void checkReadable() throws IOException { if (!modes.isReadable()) throw new IOException("not opened for reading"); }
public void checkReadable() throws IOException { if (!modes.isReadable()) throw new IOException("not opened for reading"); }
private void setupModes() { ptr.closedWrite = false; ptr.closedRead = false; if (ptr.modes.isReadOnly()) ptr.closedWrite = true; if (!ptr.modes.isReadable()) ptr.closedRead = true; }
private void setupModes() { ptr.closedWrite = false; ptr.closedRead = false; if (ptr.modes.isReadOnly()) ptr.closedWrite = true; if (!ptr.modes.isReadable()) ptr.closedRead = true; }
/** * Check whether the target set of flags is a superset of this one; used to * ensure that a file is not re-opened with more privileges than it already * had. * * @param superset The ModeFlags object which should be a superset of this one * @return true if the object is a superset, false otherwise */ public boolean isSubsetOf(ModeFlags superset) { // TODO: Make sure all appropriate open flags are added to this check. if ((!superset.isReadable() && isReadable()) || (!superset.isWritable() && isWritable()) || !superset.isAppendable() && isAppendable()) { return false; } return true; }
/** * Check whether the target set of flags is a superset of this one; used to * ensure that a file is not re-opened with more privileges than it already * had. * * @param superset The ModeFlags object which should be a superset of this one * @return true if the object is a superset, false otherwise */ public boolean isSubsetOf(ModeFlags superset) { // TODO: Make sure all appropriate open flags are added to this check. if ((!superset.isReadable() && isReadable()) || (!superset.isWritable() && isWritable()) || !superset.isAppendable() && isAppendable()) { return false; } return true; }
/** * Check whether the target set of flags is a superset of this one; used to * ensure that a file is not re-opened with more privileges than it already * had. * * @param superset The ModeFlags object which should be a superset of this one * @return true if the object is a superset, false otherwise */ public boolean isSubsetOf(ModeFlags superset) { // TODO: Make sure all appropriate open flags are added to this check. if ((!superset.isReadable() && isReadable()) || (!superset.isWritable() && isWritable()) || !superset.isAppendable() && isAppendable()) { return false; } return true; }
/** * Check whether the target set of flags is a superset of this one; used to * ensure that a file is not re-opened with more privileges than it already * had. * * @param superset The ModeFlags object which should be a superset of this one * @return true if the object is a superset, false otherwise */ public boolean isSubsetOf(ModeFlags superset) { // TODO: Make sure all appropriate open flags are added to this check. if ((!superset.isReadable() && isReadable()) || (!superset.isWritable() && isWritable()) || !superset.isAppendable() && isAppendable()) { return false; } return true; }
@Override public String toString() { StringBuilder buf = new StringBuilder("ModeFlags(" + flags + "): "); if (isAppendable()) buf.append("APPENDABLE "); if (isBinary()) buf.append("BINARY "); if (isCreate()) buf.append("CREATE "); if (isExclusive()) buf.append("EXCLUSIVE "); if (isReadOnly()) buf.append("READONLY "); if (isText()) buf.append("TEXT "); if (isTruncate()) buf.append("TRUNCATE "); if (isWritable()) { if (isReadable()) { buf.append("RDWR"); } else { buf.append("WRITABLE "); } } return buf.toString(); }
@Override public String toString() { StringBuilder buf = new StringBuilder("ModeFlags(" + flags + "): "); if (isAppendable()) buf.append("APPENDABLE "); if (isBinary()) buf.append("BINARY "); if (isCreate()) buf.append("CREATE "); if (isExclusive()) buf.append("EXCLUSIVE "); if (isReadOnly()) buf.append("READONLY "); if (isText()) buf.append("TEXT "); if (isTruncate()) buf.append("TRUNCATE "); if (isWritable()) { if (isReadable()) { buf.append("RDWR"); } else { buf.append("WRITABLE "); } } return buf.toString(); }
@Override public String toString() { StringBuilder buf = new StringBuilder(); buf.append("ModeFlags(").append(flags).append("): "); if (isAppendable()) buf.append("APPENDABLE "); if (isBinary()) buf.append("BINARY "); if (isCreate()) buf.append("CREATE "); if (isExclusive()) buf.append("EXCLUSIVE "); if (isReadOnly()) buf.append("READONLY "); if (isText()) buf.append("TEXT "); if (isTemporary()) buf.append("TMPFILE "); if (isTruncate()) buf.append("TRUNCATE "); if (isWritable()) { if (isReadable()) { buf.append("RDWR"); } else { buf.append("WRITABLE "); } } return buf.toString(); }
private void checkReadable() { checkFrozen(); checkInitialized(); if (ptr.closedRead || !ptr.modes.isReadable()) { throw getRuntime().newIOError("not opened for reading"); } }
public POpenProcess(Process child, Ruby runtime, ModeFlags modes) { this.child = child; if (modes.isWritable()) { this.waitForChild = true; prepareOutput(child); } else { this.waitForChild = false; // close process output // See JRUBY-3405; hooking up to parent process stdin caused // problems for IRB etc using stdin. try {child.getOutputStream().close();} catch (IOException ioe) {} } if (modes.isReadable()) { prepareInput(child); } else { pumpInput(child, runtime); } pumpInerr(child, runtime); }
public POpenProcess(Process child, Ruby runtime, ModeFlags modes) { this.child = child; if (modes.isWritable()) { this.waitForChild = true; prepareOutput(child); } else { this.waitForChild = false; // close process output // See JRUBY-3405; hooking up to parent process stdin caused // problems for IRB etc using stdin. try {child.getOutputStream().close();} catch (IOException ioe) {} } if (modes.isReadable()) { prepareInput(child); } else { pumpInput(child, runtime); } pumpInerr(child, runtime); }
public POpenProcess(Process child, Ruby runtime, ModeFlags modes) { this.child = child; if (modes.isWritable()) { this.waitForChild = true; prepareOutput(child); } else { this.waitForChild = false; // close process output // See JRUBY-3405; hooking up to parent process stdin caused // problems for IRB etc using stdin. try {child.getOutputStream().close();} catch (IOException ioe) {} } if (modes.isReadable()) { prepareInput(child); } else { pumpInput(child, runtime); } pumpInerr(child, runtime); }
public POpenProcess(Process child, Ruby runtime, ModeFlags modes) { this.child = child; if (modes.isWritable()) { this.waitForChild = true; prepareOutput(child); } else { this.waitForChild = false; // close process output // See JRUBY-3405; hooking up to parent process stdin caused // problems for IRB etc using stdin. try {child.getOutputStream().close();} catch (IOException ioe) {} } if (modes.isReadable()) { prepareInput(child); } else { pumpInput(child, runtime); } pumpInerr(child, runtime); }
private void checkReadable() { checkFrozen(); checkInitialized(); if (ptr.closedRead || !ptr.modes.isReadable()) { throw getRuntime().newIOError("not opened for reading"); } }
/** * 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(); }