/** * Gets the file system path of this socket address * * @return A String */ public final java.lang.String getPath() { return getPathField().get(); }
/** * Sets the file system path of this socket address * * @param path The unix socket address */ void setPath(java.lang.String path) { cachedPath = path; getPathField().set(cachedPath); }
/** * Sets the file system path of this socket address * * @param path The unix socket address */ public final void setPath(java.lang.String path) { getPathField().set(path); }
/** * Gets the maximum length of this address (including len/family header) * * @return The maximum size of the address in bytes */ public int getMaximumLength() { return 2 + getPathField().length(); }
/** * Gets the maximum length of this address (including len/family header) * * @return The maximum size of the address in bytes */ int getMaximumLength() { return HEADER_LENGTH + getPathField().length(); }
/** * Gets the actual length of this address (including len/family header) * * @return The actual size of this address, in bytes */ int length() { if (currentOS == OS.LINUX && null != cachedPath) { return HEADER_LENGTH + cachedPath.length(); } return HEADER_LENGTH + strlen(getPathField()); }
/** * Gets the file system path of this socket address * * @return A String */ final java.lang.String getPath() { if (null == cachedPath) { cachedPath = getPathField().get(); } return cachedPath; }
/** * Gets the actual length of this address (including len/family header) * * @return The actual size of this address, in bytes */ public int length() { return 2 + strlen(getPathField()); }
/** * Updates the file system path of this socket address. * In order to support abstract namespaces, this MUST be * called after any native syscall that sets this * path struct like getsockname(), getpeername(), accept(). * * @param len the value of the addrlen var, set by the above syscalls. */ void updatePath(final int len) { if (currentOS == OS.LINUX) { // Linux always returns an accurate length in // order to support abstract namespace, where // path STARTS with a NUL byte. cachedPath = len == HEADER_LENGTH ? "" : getPath(len - HEADER_LENGTH); } else { // All others might return a len > 0 (typically 14) AND the path is terminated // by a NUL byte if it is shorter than sizeof(sun_path) cachedPath = getPathField().get(); int slen = len - HEADER_LENGTH; if (slen <= 0) { cachedPath = ""; } else { if (slen < getPathField().length() && slen < cachedPath.length()) { cachedPath = cachedPath.substring(0, slen); } } } }
/** * Gets the path of this socket address, supporting abstract namespace on Linux. * * @param len The desired length of the string. * If the first character of the path is NUL, then this value ist considered * exact, otherwise it includes a trailing NUL charater and therefore the actual * string length is len - 1. */ final java.lang.String getPath(int len) { UTF8String str = getPathField(); byte [] ba = new byte[str.length()]; str.getMemory().get(str.offset(), ba, 0, len); if (0 != ba[0]) { len -= 1; } return new java.lang.String(java.util.Arrays.copyOf(ba, len), UTF_8); }