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(); }
@Override public void finalize(Ruby runtime, OpenFile fptr, boolean noraise) { if (!Platform.IS_WINDOWS) { // #if !defined(HAVE_FORK) && !defined(_WIN32) int status = 0; if (fptr.stdio_file != null) { // unsure how to do this // status = pclose(fptr->stdio_file); fptr.posix.close(fptr.stdio_file); } fptr.setFD(null); fptr.stdio_file = null; // no status from above, so can't really do this // runtime.getCurrentContext().setLastExitStatus(); } else { fptr.finalize(runtime.getCurrentContext(), noraise); } // pipe_del_fptr(fptr); } };
@Override public void finalize(Ruby runtime, OpenFile fptr, boolean noraise) { if (!Platform.IS_WINDOWS) { // #if !defined(HAVE_FORK) && !defined(_WIN32) int status = 0; if (fptr.stdio_file != null) { // unsure how to do this // status = pclose(fptr->stdio_file); fptr.posix.close(fptr.stdio_file); } fptr.setFD(null); fptr.stdio_file = null; // no status from above, so can't really do this // runtime.getCurrentContext().setLastExitStatus(); } else { fptr.finalize(runtime.getCurrentContext(), noraise); } // pipe_del_fptr(fptr); } };
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 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 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); }
public IRubyObject fileOpenGeneric(ThreadContext context, IRubyObject filename, int oflags, int fmode, IOEncodable convConfig, int perm) { if (convConfig == null) { convConfig = new ConvConfig(); EncodingUtils.ioExtIntToEncs(context, convConfig, null, null, fmode); convConfig.setEcflags(0); convConfig.setEcopts(context.nil); } int[] fmode_p = {fmode}; EncodingUtils.validateEncodingBinmode(context, fmode_p, convConfig.getEcflags(), convConfig); OpenFile fptr = MakeOpenFile(); fptr.setMode(fmode_p[0]); fptr.encs.copy(convConfig); fptr.setPath(adjustRootPathOnWindows(context.runtime, RubyFile.get_path(context, filename).asJavaString(), getRuntime().getCurrentDirectory())); fptr.setFD(sysopen(context.runtime, fptr.getPath(), oflags, perm)); fptr.checkTTY(); if ((fmode_p[0] & OpenFile.SETENC_BY_BOM) != 0) { EncodingUtils.ioSetEncodingByBOM(context, this); } return this; }
public IRubyObject fileOpenGeneric(ThreadContext context, IRubyObject filename, int oflags, int fmode, IOEncodable convConfig, int perm) { if (convConfig == null) { convConfig = new ConvConfig(); EncodingUtils.ioExtIntToEncs(context, convConfig, null, null, fmode); convConfig.setEcflags(0); convConfig.setEcopts(context.nil); } int[] fmode_p = {fmode}; EncodingUtils.validateEncodingBinmode(context, fmode_p, convConfig.getEcflags(), convConfig); OpenFile fptr = MakeOpenFile(); fptr.setMode(fmode_p[0]); fptr.encs.copy(convConfig); fptr.setPath(adjustRootPathOnWindows(context.runtime, RubyFile.get_path(context, filename).asJavaString(), getRuntime().getCurrentDirectory())); fptr.setFD(sysopen(context.runtime, fptr.getPath(), oflags, perm)); fptr.checkTTY(); if ((fmode_p[0] & OpenFile.SETENC_BY_BOM) != 0) { EncodingUtils.ioSetEncodingByBOM(context, this); } return this; }
runtime.defineGlobalConstant("STDERR", stderr); } else { ((RubyIO) runtime.getObject().getConstant("STDIN")).getOpenFile().setFD(stdin.getOpenFile().fd()); ((RubyIO) runtime.getObject().getConstant("STDOUT")).getOpenFile().setFD(stdout.getOpenFile().fd()); ((RubyIO) runtime.getObject().getConstant("STDERR")).getOpenFile().setFD(stderr.getOpenFile().fd());
runtime.defineGlobalConstant("STDERR", stderr); } else { ((RubyIO) runtime.getObject().getConstant("STDIN")).getOpenFile().setFD(stdin.getOpenFile().fd()); ((RubyIO) runtime.getObject().getConstant("STDOUT")).getOpenFile().setFD(stdout.getOpenFile().fd()); ((RubyIO) runtime.getObject().getConstant("STDERR")).getOpenFile().setFD(stderr.getOpenFile().fd());
openFile.setFD(fd); openFile.setMode(fmode_p[0]); openFile.encs = convconfig;
openFile.setFD(fd); openFile.setMode(fmode_p[0]); openFile.encs = convconfig;
fptr.setFD(fd); pos = orig.tell(context); if (pos == -1)
fptr.setFD(fd); pos = orig.tell(context); if (pos == -1)