protected void initSocket(ChannelFD fd) { // continue with normal initialization MakeOpenFile(); openFile.setFD(fd); openFile.setMode(OpenFile.READWRITE | OpenFile.SYNC); // see rsock_init_sock in MRI; sockets are initialized to binary setAscii8bitBinmode(); }
protected void initSocket(ChannelFD fd) { // continue with normal initialization MakeOpenFile(); openFile.setFD(fd); openFile.setMode(OpenFile.READWRITE | OpenFile.SYNC); // see rsock_init_sock in MRI; sockets are initialized to binary setAscii8bitBinmode(); }
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); }
protected void init_sock(Ruby runtime, Channel channel, String path) { MakeOpenFile(); ModeFlags modes = newModeFlags(runtime, ModeFlags.RDWR); openFile.setFD(newChannelFD(runtime, channel)); openFile.setMode(modes.getOpenFileFlags()); openFile.setSync(true); openFile.setPath(path); }
protected void openInternal(String path, String modeString) { if (path.startsWith("jar:")) { path = path.substring(4); } MakeOpenFile(); IOOptions modes = newIOOptions(getRuntime(), modeString); openFile.setMode(modes.getModeFlags().getOpenFileFlags()); if (getRuntime().is1_9() && modes.getModeFlags().isBinary()) enc = ASCIIEncoding.INSTANCE; openFile.setPath(path); openFile.setMainStream(fopen(path, modes.getModeFlags())); }
protected void init_sock(Ruby runtime, Channel channel, String path) { MakeOpenFile(); ModeFlags modes = newModeFlags(runtime, ModeFlags.RDWR); openFile.setFD(newChannelFD(runtime, channel)); openFile.setMode(modes.getOpenFileFlags()); openFile.setSync(true); openFile.setPath(path); }
protected void openInternal(String path, String modeString) { if (path.startsWith("jar:")) { path = path.substring(4); } MakeOpenFile(); IOOptions modes = newIOOptions(getRuntime(), modeString); openFile.setMode(modes.getModeFlags().getOpenFileFlags()); if (getRuntime().is1_9() && modes.getModeFlags().isBinary()) enc = ASCIIEncoding.INSTANCE; openFile.setPath(path); openFile.setMainStream(fopen(path, modes.getModeFlags())); }
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(); } }
public RubyIO(Ruby runtime, InputStream inputStream) { super(runtime, runtime.getIO()); if (inputStream == null) { throw runtime.newRuntimeError("Opening null stream"); } openFile = MakeOpenFile(); openFile.setFD(new ChannelFD(readableChannel(inputStream), runtime.getPosix(), runtime.getFilenoUtil())); openFile.setMode(OpenFile.READABLE); }
public RubyIO(Ruby runtime, InputStream inputStream) { super(runtime, runtime.getIO()); if (inputStream == null) { throw runtime.newRuntimeError("Opening null stream"); } openFile = MakeOpenFile(); openFile.setFD(new ChannelFD(readableChannel(inputStream), runtime.getPosix(), runtime.getFilenoUtil())); 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 = MakeOpenFile(); openFile.setFD(new ChannelFD(writableChannel(outputStream), runtime.getPosix(), runtime.getFilenoUtil())); openFile.setMode(OpenFile.WRITABLE | OpenFile.APPEND); openFile.setAutoclose(autoclose); }
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 = MakeOpenFile(); openFile.setFD(new ChannelFD(writableChannel(outputStream), runtime.getPosix(), runtime.getFilenoUtil())); openFile.setMode(OpenFile.WRITABLE | OpenFile.APPEND); openFile.setAutoclose(autoclose); }
private void initializeOpen(IOOptions ioOptions) { getRuntime().getPosix().chmod(path, 0600); MakeOpenFile(); openFile.setMode(ioOptions.getModeFlags().getOpenFileFlags()); openFile.setPath(path); sysopenInternal19(path, ioOptions.getModeFlags().getOpenFileFlags(), 0600); }
private void initializeOpen(IOOptions ioOptions) { getRuntime().getPosix().chmod(path, 0600); MakeOpenFile(); openFile.setMode(ioOptions.getModeFlags().getOpenFileFlags()); openFile.setPath(path); sysopenInternal19(path, ioOptions.getModeFlags().getOpenFileFlags(), 0600); }
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()); }