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, 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); }
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 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 FileDescriptorIO(Ruby runtime, IRubyObject fd) { super(runtime, runtime.getModule("FFI").getClass(CLASS_NAME)); MakeOpenFile(); ModeFlags modes = newModeFlags(runtime, ModeFlags.RDWR); int fileno = RubyNumeric.fix2int(fd); FileStat stat = runtime.getPosix().fstat(fileno); ByteChannel channel; if (stat.isSocket()) { channel = new jnr.enxio.channels.NativeSocketChannel(fileno); } else if (stat.isBlockDev() || stat.isCharDev()) { channel = new jnr.enxio.channels.NativeDeviceChannel(fileno); } else { channel = new FileDescriptorByteChannel(runtime, fileno); } // openFile.setMainStream(ChannelStream.open(getRuntime(), new ChannelDescriptor(channel, modes, FileDescriptorHelper.wrap(fileno)))); openFile.setChannel(channel); openFile.setMode(modes.getOpenFileFlags()); openFile.setMode(modes.getOpenFileFlags()); openFile.setSync(true); }
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 FileDescriptorIO(Ruby runtime, IRubyObject fd) { super(runtime, runtime.getModule("FFI").getClass(CLASS_NAME)); MakeOpenFile(); ModeFlags modes = newModeFlags(runtime, ModeFlags.RDWR); int fileno = RubyNumeric.fix2int(fd); FileStat stat = runtime.getPosix().fstat(fileno); ByteChannel channel; if (stat.isSocket()) { channel = new jnr.enxio.channels.NativeSocketChannel(fileno); } else if (stat.isBlockDev() || stat.isCharDev()) { channel = new jnr.enxio.channels.NativeDeviceChannel(fileno); } else { channel = new FileDescriptorByteChannel(runtime, fileno); } // openFile.setMainStream(ChannelStream.open(getRuntime(), new ChannelDescriptor(channel, modes, FileDescriptorHelper.wrap(fileno)))); openFile.setChannel(channel); openFile.setMode(modes.getOpenFileFlags()); openFile.setMode(modes.getOpenFileFlags()); openFile.setSync(true); }
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()); }
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()); }
openFile.setMode(openFile.getMainStream().getModes().getOpenFileFlags());
openFile.setMode(openFile.getMainStream().getModes().getOpenFileFlags());
private IRubyObject openFile(IRubyObject args[]) { Ruby runtime = getRuntime(); RubyString filename = get_path(runtime.getCurrentContext(), args[0]); path = adjustRootPathOnWindows(runtime, filename.asJavaString(), runtime.getCurrentDirectory()); String modeString; IOOptions modes; int perm; if ((args.length > 1 && args[1] instanceof RubyFixnum) || (args.length > 2 && !args[2].isNil())) { modes = parseIOOptions(args[1]); perm = getFilePermissions(args); MakeOpenFile(); openFile.setMode(modes.getModeFlags().getOpenFileFlags()); openFile.setPath(path); sysopenInternal(path, modes.getModeFlags(), perm); } else { modeString = "r"; if (args.length > 1 && !args[1].isNil()) { modeString = args[1].convertToString().toString(); } openInternal(path, modeString); } return this; }
private IRubyObject openFile(IRubyObject args[]) { Ruby runtime = getRuntime(); RubyString filename = get_path(runtime.getCurrentContext(), args[0]); path = adjustRootPathOnWindows(runtime, filename.asJavaString(), runtime.getCurrentDirectory()); String modeString; IOOptions modes; int perm; if ((args.length > 1 && args[1] instanceof RubyFixnum) || (args.length > 2 && !args[2].isNil())) { modes = parseIOOptions(args[1]); perm = getFilePermissions(args); MakeOpenFile(); openFile.setMode(modes.getModeFlags().getOpenFileFlags()); openFile.setPath(path); sysopenInternal(path, modes.getModeFlags(), perm); } else { modeString = "r"; if (args.length > 1 && !args[1].isNil()) { modeString = args[1].convertToString().toString(); } openInternal(path, modeString); } return this; }
public FileDescriptorIO(Ruby runtime, IRubyObject fd) { super(runtime, runtime.getModule("FFI").getClass(CLASS_NAME)); MakeOpenFile(); ModeFlags modes; try { modes = newModeFlags(runtime, ModeFlags.RDWR); int fileno = RubyNumeric.fix2int(fd); jnr.posix.FileStat stat = runtime.getPosix().fstat(fileno); java.nio.channels.ByteChannel channel; if (stat.isSocket()) { channel = new jnr.enxio.channels.NativeSocketChannel(fileno); } else if (stat.isBlockDev() || stat.isCharDev()) { channel = new jnr.enxio.channels.NativeDeviceChannel(fileno); } else { channel = new FileDescriptorByteChannel(runtime, fileno); } openFile.setMainStream(ChannelStream.open(getRuntime(), new ChannelDescriptor(channel, modes, FileDescriptorHelper.wrap(fileno)))); openFile.setPipeStream(openFile.getMainStreamSafe()); openFile.setMode(modes.getOpenFileFlags()); openFile.getMainStreamSafe().setSync(true); } catch (BadDescriptorException e) { throw runtime.newErrnoEBADFError(); } }
public FileDescriptorIO(Ruby runtime, IRubyObject fd) { super(runtime, runtime.getModule("FFI").getClass(CLASS_NAME)); MakeOpenFile(); ModeFlags modes; try { modes = newModeFlags(runtime, ModeFlags.RDWR); int fileno = RubyNumeric.fix2int(fd); jnr.posix.FileStat stat = runtime.getPosix().fstat(fileno); java.nio.channels.ByteChannel channel; if (stat.isSocket()) { channel = new jnr.enxio.channels.NativeSocketChannel(fileno); } else if (stat.isBlockDev() || stat.isCharDev()) { channel = new jnr.enxio.channels.NativeDeviceChannel(fileno); } else { channel = new FileDescriptorByteChannel(runtime, fileno); } openFile.setMainStream(ChannelStream.open(getRuntime(), new ChannelDescriptor(channel, modes, FileDescriptorHelper.wrap(fileno)))); openFile.setPipeStream(openFile.getMainStreamSafe()); openFile.setMode(modes.getOpenFileFlags()); openFile.getMainStreamSafe().setSync(true); } catch (BadDescriptorException e) { throw runtime.newErrnoEBADFError(); } }