< prev index next >

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

Print this page
rev 54189 : 8213031: (zipfs) Add support for POSIX file permissions

*** 1,7 **** /* ! * Copyright (c) 2009, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this --- 1,7 ---- /* ! * Copyright (c) 2009, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this
*** 36,45 **** --- 36,46 ---- import java.nio.file.*; import java.nio.file.DirectoryStream.Filter; import java.nio.file.attribute.BasicFileAttributes; import java.nio.file.attribute.FileAttribute; import java.nio.file.attribute.FileAttributeView; + import java.nio.file.attribute.PosixFileAttributes; import java.nio.file.spi.FileSystemProvider; import java.security.AccessController; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import java.util.HashMap;
*** 129,145 **** @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; --- 130,146 ---- @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;
*** 289,309 **** @SuppressWarnings("unchecked") // Cast to A public <A extends BasicFileAttributes> A readAttributes(Path path, Class<A> type, LinkOption... options) throws IOException { ! if (type == BasicFileAttributes.class || type == ZipFileAttributes.class) return (A)toZipPath(path).getAttributes(); ! return null; } @Override public Map<String, Object> ! readAttributes(Path path, String attribute, LinkOption... options) throws IOException { ! return toZipPath(path).readAttributes(attribute, options); } @Override public Path readSymbolicLink(Path link) throws IOException { throw new UnsupportedOperationException("Not supported."); --- 290,324 ---- @SuppressWarnings("unchecked") // Cast to A public <A extends BasicFileAttributes> A readAttributes(Path path, Class<A> type, LinkOption... options) throws IOException { ! // unconditionally support BasicFileAttributes and ZipFileAttributes ! if (type == BasicFileAttributes.class || ! type == ZipFileAttributes.class) ! { return (A)toZipPath(path).getAttributes(); ! } ! ! // support PosixFileAttributes when activated ! if (type == PosixFileAttributes.class) { ! ZipPath zpath = toZipPath(path); ! if (zpath.zfs.supportPosix) { ! return (A)zpath.getAttributes(); ! } ! } ! ! throw new UnsupportedOperationException("Attributes of type " + ! type.getName() + " not supported"); } @Override public Map<String, Object> ! readAttributes(Path path, String attributes, LinkOption... options) throws IOException { ! return toZipPath(path).readAttributes(attributes, options); } @Override public Path readSymbolicLink(Path link) throws IOException { throw new UnsupportedOperationException("Not supported.");
< prev index next >