--- old/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipFileAttributeView.java 2018-12-18 16:24:48.917818000 +0100 +++ new/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipFileAttributeView.java 2018-12-18 16:24:48.080780800 +0100 @@ -29,13 +29,18 @@ import java.nio.file.attribute.BasicFileAttributeView; import java.nio.file.attribute.FileAttributeView; import java.nio.file.attribute.FileTime; +import java.nio.file.attribute.GroupPrincipal; +import java.nio.file.attribute.PosixFileAttributeView; +import java.nio.file.attribute.PosixFilePermission; +import java.nio.file.attribute.UserPrincipal; import java.util.LinkedHashMap; import java.util.Map; +import java.util.Set; /** * @author Xueming Shen, Rajendra Gutupalli, Jaya Hangal */ -class ZipFileAttributeView implements BasicFileAttributeView { +class ZipFileAttributeView implements PosixFileAttributeView { private static enum AttrID { size, creationTime, @@ -48,15 +53,22 @@ fileKey, compressedSize, crc, - method + method, + permissions }; + private static enum ViewType { + zip, + posix, + basic + } + private final ZipPath path; - private final boolean isZipView; + private final ViewType type; - private ZipFileAttributeView(ZipPath path, boolean isZipView) { + private ZipFileAttributeView(ZipPath path, ViewType type) { this.path = path; - this.isZipView = isZipView; + this.type = type; } @SuppressWarnings("unchecked") // Cast to V @@ -64,9 +76,11 @@ if (type == null) throw new NullPointerException(); if (type == BasicFileAttributeView.class) - return (V)new ZipFileAttributeView(path, false); + return (V)new ZipFileAttributeView(path, ViewType.basic); + if (type == PosixFileAttributeView.class) + return (V)new ZipFileAttributeView(path, ViewType.posix); if (type == ZipFileAttributeView.class) - return (V)new ZipFileAttributeView(path, true); + return (V)new ZipFileAttributeView(path, ViewType.zip); return null; } @@ -74,15 +88,25 @@ if (type == null) throw new NullPointerException(); if (type.equals("basic")) - return new ZipFileAttributeView(path, false); + return new ZipFileAttributeView(path, ViewType.basic); + if (type.equals("posix")) + return new ZipFileAttributeView(path, ViewType.posix); if (type.equals("zip")) - return new ZipFileAttributeView(path, true); + return new ZipFileAttributeView(path, ViewType.zip); return null; } @Override public String name() { - return isZipView ? "zip" : "basic"; + switch (type) { + case zip: + return "zip"; + case posix: + return "posix"; + case basic: + default: + return "basic"; + } } public ZipFileAttributes readAttributes() throws IOException { @@ -157,18 +181,47 @@ case fileKey: return zfas.fileKey(); case compressedSize: - if (isZipView) + if (type == ViewType.zip) return zfas.compressedSize(); break; case crc: - if (isZipView) + if (type == ViewType.zip) return zfas.crc(); break; case method: - if (isZipView) + if (type == ViewType.zip) return zfas.method(); break; + case permissions: + if (type == ViewType.zip || type == ViewType.posix) { + try { + return zfas.permissions(); + } catch (UnsupportedOperationException e) { + return null; + } + } + break; } return null; } + + @Override + public UserPrincipal getOwner() throws IOException { + throw new UnsupportedOperationException("ZipFileSystem does not support getOwner."); + } + + @Override + public void setOwner(UserPrincipal owner) throws IOException { + throw new UnsupportedOperationException("ZipFileSystem does not support setOwner."); + } + + @Override + public void setPermissions(Set perms) throws IOException { + path.setPermissions(perms); + } + + @Override + public void setGroup(GroupPrincipal group) throws IOException { + throw new UnsupportedOperationException("ZipFileSystem does not support setGroup."); + } }