jdk/src/share/classes/java/nio/file/attribute/PosixFilePermissions.java
changeset 8158 77d9c0f1c19f
parent 5506 202f599c92aa
child 9035 1255eb81cc2f
equal deleted inserted replaced
7988:d31b7cc371ef 8158:77d9c0f1c19f
   124      * @see #toString(Set)
   124      * @see #toString(Set)
   125      */
   125      */
   126     public static Set<PosixFilePermission> fromString(String perms) {
   126     public static Set<PosixFilePermission> fromString(String perms) {
   127         if (perms.length() != 9)
   127         if (perms.length() != 9)
   128             throw new IllegalArgumentException("Invalid mode");
   128             throw new IllegalArgumentException("Invalid mode");
   129         Set<PosixFilePermission> result = new HashSet<PosixFilePermission>();
   129         Set<PosixFilePermission> result = EnumSet.noneOf(PosixFilePermission.class);
   130         if (isR(perms.charAt(0))) result.add(OWNER_READ);
   130         if (isR(perms.charAt(0))) result.add(OWNER_READ);
   131         if (isW(perms.charAt(1))) result.add(OWNER_WRITE);
   131         if (isW(perms.charAt(1))) result.add(OWNER_WRITE);
   132         if (isX(perms.charAt(2))) result.add(OWNER_EXECUTE);
   132         if (isX(perms.charAt(2))) result.add(OWNER_EXECUTE);
   133         if (isR(perms.charAt(3))) result.add(GROUP_READ);
   133         if (isR(perms.charAt(3))) result.add(GROUP_READ);
   134         if (isW(perms.charAt(4))) result.add(GROUP_WRITE);
   134         if (isW(perms.charAt(4))) result.add(GROUP_WRITE);
   139         return result;
   139         return result;
   140     }
   140     }
   141 
   141 
   142     /**
   142     /**
   143      * Creates a {@link FileAttribute}, encapsulating a copy of the given file
   143      * Creates a {@link FileAttribute}, encapsulating a copy of the given file
   144      * permissions, suitable for passing to the {@link java.nio.file.Path#createFile
   144      * permissions, suitable for passing to the {@link java.nio.file.Files#createFile
   145      * createFile} or {@link java.nio.file.Path#createDirectory createDirectory}
   145      * createFile} or {@link java.nio.file.Files#createDirectory createDirectory}
   146      * methods.
   146      * methods.
   147      *
   147      *
   148      * @param   perms
   148      * @param   perms
   149      *          the set of permissions
   149      *          the set of permissions
   150      *
   150      *