< prev index next >

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

Print this page

        

*** 51,60 **** --- 51,62 ---- /** * @author Xueming Shen, Rajendra Gutupalli, Jaya Hangal */ public class ZipFileSystemProvider extends FileSystemProvider { + protected static final String RELEASE_VERSION = "releaseVersion"; + protected static final String MULTI_RELEASE = "multi-release"; private final Map<Path, ZipFileSystem> filesystems = new HashMap<>(); public ZipFileSystemProvider() {} @Override
*** 102,125 **** if (ensureFile(path)) { realPath = path.toRealPath(); if (filesystems.containsKey(realPath)) throw new FileSystemAlreadyExistsException(); } ! ZipFileSystem zipfs; ! try { ! if (env.containsKey("multi-release")) { ! zipfs = new JarFileSystem(this, path, env); ! } else { ! zipfs = new ZipFileSystem(this, path, env); ! } ! } catch (ZipException ze) { ! String pname = path.toString(); ! if (pname.endsWith(".zip") || pname.endsWith(".jar")) ! throw ze; ! // assume NOT a zip/jar file ! throw new UnsupportedOperationException(); ! } if (realPath == null) { // newly created realPath = path.toRealPath(); } filesystems.put(realPath, zipfs); return zipfs; --- 104,114 ---- if (ensureFile(path)) { realPath = path.toRealPath(); if (filesystems.containsKey(realPath)) throw new FileSystemAlreadyExistsException(); } ! ZipFileSystem zipfs = getZipFileSystem(path, env); if (realPath == null) { // newly created realPath = path.toRealPath(); } filesystems.put(realPath, zipfs); return zipfs;
*** 129,152 **** @Override public FileSystem newFileSystem(Path path, Map<String, ?> env) throws IOException { ensureFile(path); ! try { ZipFileSystem zipfs; ! if (env.containsKey("multi-release")) { zipfs = new JarFileSystem(this, path, env); } else { zipfs = new ZipFileSystem(this, path, env); } - return zipfs; } catch (ZipException ze) { String pname = path.toString(); if (pname.endsWith(".zip") || pname.endsWith(".jar")) throw ze; throw new UnsupportedOperationException(); } } @Override public Path getPath(URI uri) { String spec = uri.getSchemeSpecificPart(); --- 118,147 ---- @Override public FileSystem newFileSystem(Path path, Map<String, ?> env) throws IOException { ensureFile(path); ! ZipFileSystem zipfs = getZipFileSystem(path, env); ! return zipfs; ! } ! ! private ZipFileSystem getZipFileSystem(Path path, Map<String, ?> env) throws IOException { ZipFileSystem zipfs; ! try { ! if (env.containsKey(RELEASE_VERSION) || ! env.containsKey(MULTI_RELEASE)) { zipfs = new JarFileSystem(this, path, env); } else { zipfs = new ZipFileSystem(this, path, env); } } catch (ZipException ze) { String pname = path.toString(); if (pname.endsWith(".zip") || pname.endsWith(".jar")) throw ze; throw new UnsupportedOperationException(); } + return zipfs; } @Override public Path getPath(URI uri) { String spec = uri.getSchemeSpecificPart();
< prev index next >