src/solaris/classes/sun/nio/fs/UnixPath.java

Print this page

        

*** 66,76 **** this.path = path; } UnixPath(UnixFileSystem fs, String input) { // removes redundant slashes and checks for invalid characters ! this(fs, encode(normalizeAndCheck(input))); } // package-private // removes redundant slashes and check input for invalid characters static String normalizeAndCheck(String input) { --- 66,76 ---- this.path = path; } UnixPath(UnixFileSystem fs, String input) { // removes redundant slashes and checks for invalid characters ! this(fs, encode(fs, normalizeAndCheck(input))); } // package-private // removes redundant slashes and check input for invalid characters static String normalizeAndCheck(String input) {
*** 114,134 **** } return sb.toString(); } // encodes the given path-string into a sequence of bytes ! private static byte[] encode(String input) { SoftReference<CharsetEncoder> ref = encoder.get(); CharsetEncoder ce = (ref != null) ? ref.get() : null; if (ce == null) { ce = Charset.defaultCharset().newEncoder() .onMalformedInput(CodingErrorAction.REPORT) .onUnmappableCharacter(CodingErrorAction.REPORT); encoder.set(new SoftReference<CharsetEncoder>(ce)); } ! char[] ca = input.toCharArray(); // size output buffer for worse-case size byte[] ba = new byte[(int)(ca.length * (double)ce.maxBytesPerChar())]; // encode --- 114,134 ---- } return sb.toString(); } // encodes the given path-string into a sequence of bytes ! private static byte[] encode(UnixFileSystem fs, String input) { SoftReference<CharsetEncoder> ref = encoder.get(); CharsetEncoder ce = (ref != null) ? ref.get() : null; if (ce == null) { ce = Charset.defaultCharset().newEncoder() .onMalformedInput(CodingErrorAction.REPORT) .onUnmappableCharacter(CodingErrorAction.REPORT); encoder.set(new SoftReference<CharsetEncoder>(ce)); } ! char[] ca = fs.normalizeNativePath(input.toCharArray()); // size output buffer for worse-case size byte[] ba = new byte[(int)(ca.length * (double)ce.maxBytesPerChar())]; // encode
*** 712,738 **** return true; } @Override public int compareTo(Path other) { ! int len1 = path.length; ! int len2 = ((UnixPath) other).path.length; ! ! int n = Math.min(len1, len2); ! byte v1[] = path; ! byte v2[] = ((UnixPath) other).path; ! ! int k = 0; ! while (k < n) { ! int c1 = v1[k] & 0xff; ! int c2 = v2[k] & 0xff; ! if (c1 != c2) { ! return c1 - c2; ! } ! k++; ! } ! return len1 - len2; } @Override public boolean equals(Object ob) { if ((ob != null) && (ob instanceof UnixPath)) { --- 712,722 ---- return true; } @Override public int compareTo(Path other) { ! return fs.comparePaths(this, (UnixPath) other); } @Override public boolean equals(Object ob) { if ((ob != null) && (ob instanceof UnixPath)) {
*** 742,766 **** } @Override public int hashCode() { // OK if two or more threads compute hash ! int h = hash; ! if (h == 0) { ! for (int i = 0; i< path.length; i++) { ! h = 31*h + (path[i] & 0xff); } ! hash = h; ! } ! return h; } @Override public String toString() { // OK if two or more threads create a String ! if (stringValue == null) ! stringValue = new String(path); // platform encoding return stringValue; } // -- file operations -- --- 726,747 ---- } @Override public int hashCode() { // OK if two or more threads compute hash ! if (hash == 0) { ! hash = fs.hashCodePath(this); } ! return hash; } @Override public String toString() { // OK if two or more threads create a String ! if (stringValue == null) { ! stringValue = fs.normalizeJavaPath(new String(path)); // platform encoding ! } return stringValue; } // -- file operations --