public ChannelDescriptor reopen(Channel channel, ModeFlags modes) { return new ChannelDescriptor(channel, internalFileno, modes, fileDescriptor); }
public ChannelDescriptor reopen(Channel channel, ModeFlags modes) { return new ChannelDescriptor(channel, internalFileno, modes, fileDescriptor); }
public ChannelDescriptor reopen(Channel channel, ModeFlags modes) { return new ChannelDescriptor(channel, internalFileno, modes, fileDescriptor); }
/** * Mimics the POSIX dup2(2) function, returning a new descriptor that references * the same open channel but with a specified fileno. * * @param fileno The fileno to use for the new descriptor * @return A duplicate ChannelDescriptor based on this one */ public ChannelDescriptor dup2(int fileno) { synchronized (refCounter) { refCounter.incrementAndGet(); if (DEBUG) LOG.info("Reopen fileno {}, refs now: {}", fileno, refCounter.get()); return new ChannelDescriptor(channel, fileno, originalModes, fileDescriptor, refCounter, canBeSeekable, isInAppendMode); } }
/** * Mimics the POSIX dup2(2) function, returning a new descriptor that references * the same open channel but with a specified fileno. * * @param fileno The fileno to use for the new descriptor * @return A duplicate ChannelDescriptor based on this one */ public ChannelDescriptor dup2(int fileno) { synchronized (refCounter) { refCounter.incrementAndGet(); if (DEBUG) LOG.info("Reopen fileno {}, refs now: {}", fileno, refCounter.get()); return new ChannelDescriptor(channel, fileno, originalModes, fileDescriptor, refCounter, canBeSeekable, isInAppendMode); } }
public ChannelDescriptor reopen(RandomAccessFile file, ModeFlags modes) throws IOException { return new ChannelDescriptor(file.getChannel(), internalFileno, modes, file.getFD()); }
public ChannelDescriptor reopen(RandomAccessFile file, ModeFlags modes) throws IOException { return new ChannelDescriptor(file.getChannel(), internalFileno, modes, file.getFD()); }
protected static ChannelDescriptor newChannelDescriptor(Ruby runtime, Channel channel) { ModeFlags modeFlags = newModeFlags(runtime, ModeFlags.RDWR); return new ChannelDescriptor(channel, modeFlags); }
/** * Mimics the POSIX dup(2) function, returning a new descriptor that references * the same open channel. * * @return A duplicate ChannelDescriptor based on this one */ public ChannelDescriptor dup() { synchronized (refCounter) { refCounter.incrementAndGet(); int newFileno = getNewFileno(); if (DEBUG) LOG.info("Reopen fileno {}, refs now: {}", newFileno, refCounter.get()); return new ChannelDescriptor(channel, newFileno, originalModes, fileDescriptor, refCounter, canBeSeekable, isInAppendMode); } }
protected static ChannelDescriptor newChannelDescriptor(Ruby runtime, Channel channel) { ModeFlags modeFlags = newModeFlags(runtime, ModeFlags.RDWR); return new ChannelDescriptor(channel, modeFlags); }
/** * Mimics the POSIX dup(2) function, returning a new descriptor that references * the same open channel. * * @return A duplicate ChannelDescriptor based on this one */ public ChannelDescriptor dup() { synchronized (refCounter) { refCounter.incrementAndGet(); int newFileno = getNewFileno(); if (DEBUG) LOG.info("Reopen fileno {}, refs now: {}", newFileno, refCounter.get()); return new ChannelDescriptor(channel, newFileno, originalModes, fileDescriptor, refCounter, canBeSeekable, isInAppendMode); } }
protected ChannelDescriptor initChannel(Ruby runtime) { Channel channel; try { if(soType == Sock.SOCK_STREAM) { channel = ServerSocketChannel.open(); } else { throw runtime.newArgumentError("unsupported server socket type `" + soType + "'"); } ModeFlags modeFlags = newModeFlags(runtime, ModeFlags.RDWR); return new ChannelDescriptor(channel, modeFlags); } catch(IOException e) { throw SocketUtils.sockerr(runtime, "initialize: " + e.toString()); } }
public RubyIO(Ruby runtime, InputStream inputStream) { super(runtime, runtime.getIO()); if (inputStream == null) { throw runtime.newRuntimeError("Opening null stream"); } openFile = new OpenFile(); try { openFile.setMainStream(ChannelStream.open(runtime, new ChannelDescriptor(Channels.newChannel(inputStream)))); } catch (InvalidValueException e) { throw getRuntime().newErrnoEINVALError(); } openFile.setMode(OpenFile.READABLE); }
public RubyIO(Ruby runtime, InputStream inputStream) { super(runtime, runtime.getIO()); if (inputStream == null) { throw runtime.newRuntimeError("Opening null stream"); } openFile = new OpenFile(); try { openFile.setMainStream(ChannelStream.open(runtime, new ChannelDescriptor(Channels.newChannel(inputStream)))); } catch (InvalidValueException e) { throw getRuntime().newErrnoEINVALError(); } openFile.setMode(OpenFile.READABLE); }
public RubyIO(Ruby runtime, OutputStream outputStream, boolean autoclose) { super(runtime, runtime.getIO()); // We only want IO objects with valid streams (better to error now). if (outputStream == null) { throw runtime.newRuntimeError("Opening null stream"); } openFile = new OpenFile(); try { openFile.setMainStream(ChannelStream.open(runtime, new ChannelDescriptor(Channels.newChannel(outputStream)), autoclose)); } catch (InvalidValueException e) { throw getRuntime().newErrnoEINVALError(); } openFile.setMode(OpenFile.WRITABLE | OpenFile.APPEND); }
public RubyFile(Ruby runtime, String path, InputStream in) { super(runtime, runtime.getFile()); MakeOpenFile(); this.path = path; try { this.openFile.setMainStream(ChannelStream.open(runtime, new ChannelDescriptor(Channels.newChannel(in)))); this.openFile.setMode(openFile.getMainStreamSafe().getModes().getOpenFileFlags()); } catch (BadDescriptorException e) { throw runtime.newErrnoEBADFError(); } catch (InvalidValueException ex) { throw runtime.newErrnoEINVALError(); } }
public RubyFile(Ruby runtime, String path, InputStream in) { super(runtime, runtime.getFile()); MakeOpenFile(); this.path = path; try { this.openFile.setMainStream(ChannelStream.open(runtime, new ChannelDescriptor(Channels.newChannel(in)))); this.openFile.setMode(openFile.getMainStreamSafe().getModes().getOpenFileFlags()); } catch (BadDescriptorException e) { throw runtime.newErrnoEBADFError(); } catch (InvalidValueException ex) { throw runtime.newErrnoEINVALError(); } }
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(); } }
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(); } }
public RubyIO(Ruby runtime, Channel channel) { super(runtime, runtime.getIO()); // We only want IO objects with valid streams (better to error now). if (channel == null) { throw runtime.newRuntimeError("Opening null channel"); } openFile = new OpenFile(); try { openFile.setMainStream(ChannelStream.open(runtime, new ChannelDescriptor(channel))); } catch (InvalidValueException e) { throw getRuntime().newErrnoEINVALError(); } openFile.setMode(openFile.getMainStream().getModes().getOpenFileFlags()); }