src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipPath.java

Print this page

        

*** 374,391 **** --- 374,396 ---- if (offsets == null) { int count, index; // count names count = 0; index = 0; + if (path.length == 0) { + // empty path has one name + count = 1; + } else { while (index < path.length) { byte c = path[index++]; if (c != '/') { count++; while (index < path.length && path[index] != '/') index++; } } + } // populate offsets int[] result = new int[count]; count = 0; index = 0; while (index < path.length) {
*** 421,441 **** } // removes redundant slashs, replace "\" to zip separator "/" // and check for invalid characters private byte[] normalize(byte[] path) { ! if (path.length == 0) return path; byte prevC = 0; ! for (int i = 0; i < path.length; i++) { byte c = path[i]; if (c == '\\' || c == '\u0000') return normalize(path, i); if (c == (byte)'/' && prevC == '/') return normalize(path, i - 1); prevC = c; } return path; } private byte[] normalize(byte[] path, int off) { byte[] to = new byte[path.length]; --- 426,449 ---- } // removes redundant slashs, replace "\" to zip separator "/" // and check for invalid characters private byte[] normalize(byte[] path) { ! int len = path.length; ! if (len == 0) return path; byte prevC = 0; ! for (int i = 0; i < len; i++) { byte c = path[i]; if (c == '\\' || c == '\u0000') return normalize(path, i); if (c == (byte)'/' && prevC == '/') return normalize(path, i - 1); prevC = c; } + if (len > 1 && prevC == '/') + return Arrays.copyOf(path, len - 1); return path; } private byte[] normalize(byte[] path, int off) { byte[] to = new byte[path.length];
*** 565,575 **** WatchEvent.Kind<?>[] events, WatchEvent.Modifier... modifiers) { if (watcher == null || events == null || modifiers == null) { throw new NullPointerException(); } ! throw new UnsupportedOperationException(); } @Override public WatchKey register(WatchService watcher, WatchEvent.Kind<?>... events) { return register(watcher, events, new WatchEvent.Modifier[0]); --- 573,584 ---- WatchEvent.Kind<?>[] events, WatchEvent.Modifier... modifiers) { if (watcher == null || events == null || modifiers == null) { throw new NullPointerException(); } ! // watcher must be associated with a different provider ! throw new ProviderMismatchException(); } @Override public WatchKey register(WatchService watcher, WatchEvent.Kind<?>... events) { return register(watcher, events, new WatchEvent.Modifier[0]);