@Override public Object object(Object parameter) { if (checkStringSafety) StringSupport.checkStringSafety(((IRubyObject) parameter).getRuntime(), (IRubyObject) parameter); return ((RubyString) parameter).getByteList().unsafeBytes(); }
@JRubyMethod(name = "sysopen", required = 1, optional = 2, meta = true, compat = CompatVersion.RUBY1_9) public static IRubyObject sysopen19(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block) { RubyString path = RubyFile.get_path(context, args[0]); StringSupport.checkStringSafety(context.runtime, path); return sysopenCommon(recv, args, block, path); }
@Override public Object object(Object parameter) { if (checkStringSafety) StringSupport.checkStringSafety(((IRubyObject) parameter).getRuntime(), (IRubyObject) parameter); return ((RubyString) parameter).getByteList().unsafeBytes(); }
@Override public Object object(Object parameter) { if (checkStringSafety) StringSupport.checkStringSafety(((IRubyObject) parameter).getRuntime(), (IRubyObject) parameter); return ((RubyString) parameter).getByteList().unsafeBytes(); }
@JRubyMethod(name = "sysopen", required = 1, optional = 2, meta = true, compat = CompatVersion.RUBY1_9) public static IRubyObject sysopen19(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block) { RubyString path = RubyFile.get_path(context, args[0]); StringSupport.checkStringSafety(context.runtime, path); return sysopenCommon(recv, args, block, path); }
@Override public Object object(Object parameter) { if (checkStringSafety) StringSupport.checkStringSafety(((IRubyObject) parameter).getRuntime(), (IRubyObject) parameter); return ((RubyString) parameter).getByteList().unsafeBytes(); }
@JRubyMethod(required = 1, optional = 2, meta = true, compat = CompatVersion.RUBY1_8) public static IRubyObject sysopen(IRubyObject recv, IRubyObject[] args, Block block) { StringSupport.checkStringSafety(recv.getRuntime(), args[0]); IRubyObject pathString = args[0].convertToString(); return sysopenCommon(recv, args, block, pathString); }
@JRubyMethod(required = 1, optional = 2, meta = true, compat = CompatVersion.RUBY1_8) public static IRubyObject sysopen(IRubyObject recv, IRubyObject[] args, Block block) { StringSupport.checkStringSafety(recv.getRuntime(), args[0]); IRubyObject pathString = args[0].convertToString(); return sysopenCommon(recv, args, block, pathString); }
@JRubyMethod(name = "read", meta = true, compat = RUBY1_8) public static IRubyObject readStatic(ThreadContext context, IRubyObject recv, IRubyObject path) { StringSupport.checkStringSafety(context.runtime, path); RubyString pathStr = path.convertToString(); Ruby runtime = context.runtime; failIfDirectory(runtime, pathStr); RubyIO file = newFile(context, recv, pathStr); try { return file.read(context); } finally { file.close(); } }
@JRubyMethod(name = "read", meta = true, compat = RUBY1_8) public static IRubyObject readStatic(ThreadContext context, IRubyObject recv, IRubyObject path) { StringSupport.checkStringSafety(context.runtime, path); RubyString pathStr = path.convertToString(); Ruby runtime = context.runtime; failIfDirectory(runtime, pathStr); RubyIO file = newFile(context, recv, pathStr); try { return file.read(context); } finally { file.close(); } }
@JRubyMethod(name = "read", meta = true, compat = RUBY1_8) public static IRubyObject readStatic(ThreadContext context, IRubyObject recv, IRubyObject path, IRubyObject length) { StringSupport.checkStringSafety(context.runtime, path); RubyString pathStr = path.convertToString(); Ruby runtime = context.runtime; failIfDirectory(runtime, pathStr); RubyIO file = newFile(context, recv, pathStr); try { return !length.isNil() ? file.read(context, length) : file.read(context); } finally { file.close(); } }
@JRubyMethod(name = "read", meta = true, compat = RUBY1_8) public static IRubyObject readStatic(ThreadContext context, IRubyObject recv, IRubyObject path, IRubyObject length) { StringSupport.checkStringSafety(context.runtime, path); RubyString pathStr = path.convertToString(); Ruby runtime = context.runtime; failIfDirectory(runtime, pathStr); RubyIO file = newFile(context, recv, pathStr); try { return !length.isNil() ? file.read(context, length) : file.read(context); } finally { file.close(); } }
@JRubyMethod(name = "read", meta = true, compat = RUBY1_8) public static IRubyObject readStatic(ThreadContext context, IRubyObject recv, IRubyObject path, IRubyObject length, IRubyObject offset) { StringSupport.checkStringSafety(context.runtime, path); RubyString pathStr = path.convertToString(); Ruby runtime = context.runtime; failIfDirectory(runtime, pathStr); RubyIO file = newFile(context, recv, pathStr); try { if (!offset.isNil()) file.seek(context, offset); return !length.isNil() ? file.read(context, length) : file.read(context); } finally { file.close(); } }
@JRubyMethod(name = "read", meta = true, compat = RUBY1_8) public static IRubyObject readStatic(ThreadContext context, IRubyObject recv, IRubyObject path, IRubyObject length, IRubyObject offset) { StringSupport.checkStringSafety(context.runtime, path); RubyString pathStr = path.convertToString(); Ruby runtime = context.runtime; failIfDirectory(runtime, pathStr); RubyIO file = newFile(context, recv, pathStr); try { if (!offset.isNil()) file.seek(context, offset); return !length.isNil() ? file.read(context, length) : file.read(context); } finally { file.close(); } }
StringSupport.checkStringSafety(context.runtime, fname); fname = ((RubyString)fname).dupFrozen(); fd = sysopen(runtime, fname.toString(), oflags, perm);
StringSupport.checkStringSafety(context.runtime, fname); fname = ((RubyString)fname).dupFrozen(); fd = sysopen(runtime, fname.toString(), oflags, perm);
static MemoryIO getMemoryIO(RubyString s, boolean isDirect, boolean checkStringSafety) { Object existingHandle = s.getFFIHandle(); if (existingHandle instanceof NativeStringHandle) { NativeStringHandle sh = (NativeStringHandle) existingHandle; if (s.getByteList() == sh.bl && sh.memory.isDirect() == isDirect) { return sh.memory; } } ByteList bl = s.getByteList(); if (checkStringSafety) StringSupport.checkStringSafety(s.getRuntime(), s); MemoryIO memory; if (isDirect) { memory = TransientNativeMemoryIO.allocateAligned(s.getRuntime(), bl.length() + 1, 1, false); memory.putZeroTerminatedByteArray(0, bl.unsafeBytes(), bl.begin(), bl.length()); } else { memory = new ArrayMemoryIO(s.getRuntime(), bl.unsafeBytes(), bl.begin(), bl.length()); } s.setByteListShared(); s.setFFIHandle(new NativeStringHandle(memory, s.getByteList())); return memory; }
static MemoryIO getMemoryIO(RubyString s, boolean isDirect, boolean checkStringSafety) { Object existingHandle = s.getFFIHandle(); if (existingHandle instanceof NativeStringHandle) { NativeStringHandle sh = (NativeStringHandle) existingHandle; if (s.getByteList() == sh.bl && sh.memory.isDirect() == isDirect) { return sh.memory; } } ByteList bl = s.getByteList(); if (checkStringSafety) StringSupport.checkStringSafety(s.getRuntime(), s); MemoryIO memory; if (isDirect) { memory = TransientNativeMemoryIO.allocateAligned(s.getRuntime(), bl.length() + 1, 1, false); memory.putZeroTerminatedByteArray(0, bl.unsafeBytes(), bl.begin(), bl.length()); } else { memory = new ArrayMemoryIO(s.getRuntime(), bl.unsafeBytes(), bl.begin(), bl.length()); } s.setByteListShared(); s.setFFIHandle(new NativeStringHandle(memory, s.getByteList())); return memory; }
static MemoryIO getMemoryIO(RubyString s, boolean isDirect, boolean checkStringSafety) { Object existingHandle = s.getFFIHandle(); if (existingHandle instanceof NativeStringHandle) { NativeStringHandle sh = (NativeStringHandle) existingHandle; if (s.getByteList() == sh.bl && sh.memory.isDirect() == isDirect) { return sh.memory; } } ByteList bl = s.getByteList(); if (checkStringSafety) StringSupport.checkStringSafety(s.getRuntime(), s); MemoryIO memory; if (isDirect) { memory = TransientNativeMemoryIO.allocateAligned(s.getRuntime(), bl.length() + 1, 1, false); memory.putZeroTerminatedByteArray(0, bl.unsafeBytes(), bl.begin(), bl.length()); } else { memory = new ArrayMemoryIO(s.getRuntime(), bl.unsafeBytes(), bl.begin(), bl.length()); } s.setByteListShared(); s.setFFIHandle(new NativeStringHandle(memory, s.getByteList())); return memory; }
static MemoryIO getMemoryIO(RubyString s, boolean isDirect, boolean checkStringSafety) { Object existingHandle = s.getFFIHandle(); if (existingHandle instanceof NativeStringHandle) { NativeStringHandle sh = (NativeStringHandle) existingHandle; if (s.getByteList() == sh.bl && sh.memory.isDirect() == isDirect) { return sh.memory; } } ByteList bl = s.getByteList(); if (checkStringSafety) StringSupport.checkStringSafety(s.getRuntime(), s); MemoryIO memory; if (isDirect) { memory = TransientNativeMemoryIO.allocateAligned(s.getRuntime(), bl.length() + 1, 1, false); memory.putZeroTerminatedByteArray(0, bl.unsafeBytes(), bl.begin(), bl.length()); } else { memory = new ArrayMemoryIO(s.getRuntime(), bl.unsafeBytes(), bl.begin(), bl.length()); } s.setByteListShared(); s.setFFIHandle(new NativeStringHandle(memory, s.getByteList())); return memory; }