private void setPath(String path) { if (openFile == null) return; openFile.setPath(path); }
private void setPath(String path) { if (openFile == null) return; openFile.setPath(path); }
private static int rb_io_fptr_finalize(Ruby runtime, OpenFile fptr) { if (fptr == null) return 0; fptr.setPath(null);; if (fptr.fd() != null) fptr.cleanup(runtime, true); fptr.write_lock = null; if (fptr.rbuf.ptr != null) { fptr.rbuf.ptr = null; } if (fptr.wbuf.ptr != null) { fptr.wbuf.ptr = null; } fptr.clearCodeConversion(); return 1; }
private static int rb_io_fptr_finalize(Ruby runtime, OpenFile fptr) { if (fptr == null) return 0; fptr.setPath(null);; if (fptr.fd() != null) fptr.cleanup(runtime, true); fptr.write_lock = null; if (fptr.rbuf.ptr != null) { fptr.rbuf.ptr = null; } if (fptr.wbuf.ptr != null) { fptr.wbuf.ptr = null; } fptr.clearCodeConversion(); return 1; }
private static RubyIO prepIO(Ruby runtime, Channel fd, int fmode, RubyClass klass, String path) { OpenFile fp; RubyIO io = (RubyIO)klass.allocate(); fp = io.MakeOpenFile(); fp.setChannel(fd); // Can we determine this? // if (Platform.IS_CYGWIN) { // if (!runtime.getPosix().isatty(fd)) { // fmode |= OpenFile.BINMODE; // TODO: setmode O_BINARY means what via NIO? // setmode(fd, OpenFlags.O_BINARY); // } // } fp.setMode(fmode); fp.checkTTY(); if (path != null) fp.setPath(path); // rb_update_max_fd(fd); return io; }
private static RubyIO prepIO(Ruby runtime, Channel fd, int fmode, RubyClass klass, String path) { OpenFile fp; RubyIO io = (RubyIO)klass.allocate(); fp = io.MakeOpenFile(); fp.setChannel(fd); // Can we determine this? // if (Platform.IS_CYGWIN) { // if (!runtime.getPosix().isatty(fd)) { // fmode |= OpenFile.BINMODE; // TODO: setmode O_BINARY means what via NIO? // setmode(fd, OpenFlags.O_BINARY); // } // } fp.setMode(fmode); fp.checkTTY(); if (path != null) fp.setPath(path); // rb_update_max_fd(fd); return io; }
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); }
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 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())); }
openFile.setPath(fpath);
public IRubyObject fileOpenGeneric(ThreadContext context, IRubyObject filename, int oflags, int fmode, IOEncodable convConfig, int perm) { // unused in JRuby at the moment since we don't have a path where this happens // if (convConfig == null) { // EncodingUtils.ioExtIntToEncs(context, convConfig, null, null, fmode); // convConfig.setEcflags(0); // convConfig.setEcopts(context.nil); // } // test for null instead convConfig.getClass(); int[] fmode_p = {fmode}; EncodingUtils.validateEncodingBinmode(context, fmode_p, convConfig.getEcflags(), convConfig); MakeOpenFile(); openFile.setMode(fmode_p[0]); openFile.setPath(RubyFile.get_path(context, filename).asJavaString()); sysopenInternal19(openFile.getPath(), oflags, perm); if ((fmode & 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) { // unused in JRuby at the moment since we don't have a path where this happens // if (convConfig == null) { // EncodingUtils.ioExtIntToEncs(context, convConfig, null, null, fmode); // convConfig.setEcflags(0); // convConfig.setEcopts(context.nil); // } // test for null instead convConfig.getClass(); int[] fmode_p = {fmode}; EncodingUtils.validateEncodingBinmode(context, fmode_p, convConfig.getEcflags(), convConfig); MakeOpenFile(); openFile.setMode(fmode_p[0]); openFile.setPath(RubyFile.get_path(context, filename).asJavaString()); sysopenInternal19(openFile.getPath(), oflags, perm); if ((fmode & OpenFile.SETENC_BY_BOM) != 0) { EncodingUtils.ioSetEncodingByBOM(context, this); } return this; }
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); }
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; }
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; }