/** * Convert this Ruby string to a Java String. This version is encoding-aware. * * @return A decoded Java String, based on this Ruby string's encoding. */ public String decodeString() { return Helpers.decodeByteList(getRuntime(), value); }
/** * Convert this Ruby string to a Java String. This version is encoding-aware. * * @return A decoded Java String, based on this Ruby string's encoding. */ public String decodeString() { return Helpers.decodeByteList(getRuntime(), value); }
/** * Convert this Ruby string to a Java String. This version is encoding-aware. * * @return A decoded Java String, based on this Ruby string's encoding. */ public String decodeString() { return Helpers.decodeByteList(getRuntime(), value); }
/** * Convert this Ruby string to a Java String. This version is encoding-aware. * * @return A decoded Java String, based on this Ruby string's encoding. */ public String decodeString() { return Helpers.decodeByteList(getRuntime(), value); }
RubyString convert(ByteList str) { String s = Helpers.decodeByteList(context.runtime, str); String[] token = s.split("\\s"); ArrayList<ByteList> raw_data = new ArrayList<ByteList>(); for (int i = 0; i < token.length; i++) { raw_data.add(decodeMimeString(token[i])); } return makeRubyString(raw_data); }
RubyString convert(ByteList str) { String s = Helpers.decodeByteList(context.runtime, str); String[] token = s.split("\\s"); ArrayList<ByteList> raw_data = new ArrayList<ByteList>(); for (int i = 0; i < token.length; i++) { raw_data.add(decodeMimeString(token[i])); } return makeRubyString(raw_data); }
RubyString convert(ByteList str) { String s = Helpers.decodeByteList(context.runtime, str); String[] token = s.split("\\s"); ArrayList<ByteList> raw_data = new ArrayList<ByteList>(); for (int i = 0; i < token.length; i++) { raw_data.add(decodeMimeString(token[i])); } return makeRubyString(raw_data); }
RubyString convert(ByteList str) { String s = Helpers.decodeByteList(context.runtime, str); String[] token = s.split("\\s"); ArrayList<ByteList> raw_data = new ArrayList<ByteList>(); for (int i = 0; i < token.length; i++) { raw_data.add(decodeMimeString(token[i])); } return makeRubyString(raw_data); }
public static UnixSocketAddress addressFromSockaddr_un(ThreadContext context, IRubyObject arg) { ByteList bl = arg.convertToString().getByteList(); byte[] raw = bl.bytes(); int end = 2; for (; end < raw.length; end++) { if (raw[end] == 0) break; } ByteList path = new ByteList(raw, 2, end, false); String pathStr = Helpers.decodeByteList(context.runtime, path); return new UnixSocketAddress(new File(pathStr)); }
public static UnixSocketAddress addressFromSockaddr_un(ThreadContext context, IRubyObject arg) { ByteList bl = arg.convertToString().getByteList(); byte[] raw = bl.bytes(); int end = 2; for (; end < raw.length; end++) { if (raw[end] == 0) break; } ByteList path = new ByteList(raw, 2, end, false); String pathStr = Helpers.decodeByteList(context.runtime, path); return new UnixSocketAddress(new File(pathStr)); }
private static IRubyObject truncateCommon(ThreadContext context, IRubyObject recv, IRubyObject arg1, IRubyObject arg2) { RubyString filename = arg1.convertToString(); // TODO: SafeStringValue here Ruby runtime = context.runtime; RubyInteger newLength = arg2.convertToInteger(); File testFile ; File childFile = new File(filename.getUnicodeValue()); String filenameString = Helpers.decodeByteList(runtime, filename.getByteList()); if ( childFile.isAbsolute() ) { testFile = childFile ; } else { testFile = new File(runtime.getCurrentDirectory(), filenameString); } if (!testFile.exists()) { throw runtime.newErrnoENOENTError(filenameString); } if (newLength.getLongValue() < 0) { throw runtime.newErrnoEINVALError(filenameString); } IRubyObject[] args = new IRubyObject[] { filename, runtime.newString("r+") }; RubyFile file = (RubyFile) open(context, recv, args, Block.NULL_BLOCK); file.truncate(context, newLength); file.close(); return RubyFixnum.zero(runtime); }
private static IRubyObject truncateCommon(ThreadContext context, IRubyObject recv, IRubyObject arg1, IRubyObject arg2) { RubyString filename = arg1.convertToString(); // TODO: SafeStringValue here Ruby runtime = context.runtime; RubyInteger newLength = arg2.convertToInteger(); File testFile ; File childFile = new File(filename.getUnicodeValue() ); String filenameString = Helpers.decodeByteList(runtime, filename.getByteList()); if ( childFile.isAbsolute() ) { testFile = childFile ; } else { testFile = new File(runtime.getCurrentDirectory(), filenameString); } if (!testFile.exists()) { throw runtime.newErrnoENOENTError(filenameString); } if (newLength.getLongValue() < 0) { throw runtime.newErrnoEINVALError(filenameString); } IRubyObject[] args = new IRubyObject[] { filename, runtime.newString("r+") }; RubyFile file = (RubyFile) open(context, recv, args, Block.NULL_BLOCK); file.truncate(context, newLength); file.close(); return RubyFixnum.zero(runtime); }
private static IRubyObject truncateCommon(ThreadContext context, IRubyObject recv, IRubyObject arg1, IRubyObject arg2) { RubyString filename = arg1.convertToString(); // TODO: SafeStringValue here Ruby runtime = context.runtime; RubyInteger newLength = arg2.convertToInteger(); File testFile ; File childFile = new File(filename.getUnicodeValue()); String filenameString = Helpers.decodeByteList(runtime, filename.getByteList()); if ( childFile.isAbsolute() ) { testFile = childFile ; } else { testFile = new File(runtime.getCurrentDirectory(), filenameString); } if (!testFile.exists()) { throw runtime.newErrnoENOENTError(filenameString); } if (newLength.getLongValue() < 0) { throw runtime.newErrnoEINVALError(filenameString); } IRubyObject[] args = new IRubyObject[] { filename, runtime.newString("r+") }; RubyFile file = (RubyFile) open(context, recv, args, Block.NULL_BLOCK); file.truncate(context, newLength); file.close(); return RubyFixnum.zero(runtime); }
protected void init_unixsock(Ruby runtime, IRubyObject _path, boolean server) { ByteList path = _path.convertToString().getByteList(); String fpath = Helpers.decodeByteList(runtime, path); int maxSize = 103; // Max size from Darwin, lowest common value we know of if (fpath.length() > 103) { throw runtime.newArgumentError("too long unix socket path (max: " + maxSize + "bytes)"); } try { if (server) { UnixServerSocketChannel channel = UnixServerSocketChannel.open(); UnixServerSocket socket = channel.socket(); // TODO: listen backlog socket.bind(new UnixSocketAddress(new File(fpath))); init_sock(runtime, channel, fpath); } else { File fpathFile = new File(fpath); if (!fpathFile.exists()) { throw runtime.newErrnoENOENTError("unix socket"); } UnixSocketChannel channel = UnixSocketChannel.open(); channel.connect(new UnixSocketAddress(fpathFile)); init_sock(runtime, channel); } } catch (IOException ioe) { throw runtime.newIOErrorFromException(ioe); } }
protected void init_unixsock(Ruby runtime, IRubyObject _path, boolean server) { ByteList path = _path.convertToString().getByteList(); String fpath = Helpers.decodeByteList(runtime, path); int maxSize = 103; // Max size from Darwin, lowest common value we know of if (fpath.length() > 103) { throw runtime.newArgumentError("too long unix socket path (max: " + maxSize + "bytes)"); } try { if (server) { UnixServerSocketChannel channel = UnixServerSocketChannel.open(); UnixServerSocket socket = channel.socket(); // TODO: listen backlog socket.bind(new UnixSocketAddress(new File(fpath))); init_sock(runtime, channel, fpath); } else { File fpathFile = new File(fpath); if (!fpathFile.exists()) { throw runtime.newErrnoENOENTError("unix socket"); } UnixSocketChannel channel = UnixSocketChannel.open(); channel.connect(new UnixSocketAddress(fpathFile)); init_sock(runtime, channel); } } catch (IOException ioe) { throw runtime.newIOErrorFromException(ioe); } }
private static IRubyObject truncateCommon(ThreadContext context, IRubyObject recv, IRubyObject arg1, IRubyObject arg2) { RubyString filename = arg1.convertToString(); // TODO: SafeStringValue here Ruby runtime = context.runtime; RubyInteger newLength = arg2.convertToInteger(); File testFile ; File childFile = new File(filename.getUnicodeValue() ); String filenameString = Helpers.decodeByteList(runtime, filename.getByteList()); if ( childFile.isAbsolute() ) { testFile = childFile ; } else { testFile = new File(runtime.getCurrentDirectory(), filenameString); } if (!testFile.exists()) { throw runtime.newErrnoENOENTError(filenameString); } if (newLength.getLongValue() < 0) { throw runtime.newErrnoEINVALError(filenameString); } IRubyObject[] args = new IRubyObject[] { filename, runtime.newString("r+") }; RubyFile file = (RubyFile) open(context, recv, args, Block.NULL_BLOCK); file.truncate(context, newLength); file.close(); return RubyFixnum.zero(runtime); }
protected void init_unixsock(Ruby runtime, IRubyObject _path, boolean server) { ByteList path = _path.convertToString().getByteList(); fpath = Helpers.decodeByteList(runtime, path);
protected void init_unixsock(Ruby runtime, IRubyObject _path, boolean server) { ByteList path = _path.convertToString().getByteList(); fpath = Helpers.decodeByteList(runtime, path);