Java Posix mapValue(PosixFilePermission p)

Here you can find the source of mapValue(PosixFilePermission p)

Description

map Value

License

Open Source License

Declaration

private static int mapValue(PosixFilePermission p) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.nio.file.attribute.PosixFilePermission;

public class Main {
    private static int mapValue(PosixFilePermission p) {
        switch (p) {
        case GROUP_EXECUTE:
            return 1 * 8;
        case GROUP_READ:
            return 4 * 8;
        case GROUP_WRITE:
            return 2 * 8;
        case OWNER_EXECUTE:
            return 1 * 8 * 8;
        case OWNER_READ:
            return 4 * 8 * 8;
        case OWNER_WRITE:
            return 2 * 8 * 8;
        case OTHERS_EXECUTE:
            return 1;
        case OTHERS_READ:
            return 4;
        case OTHERS_WRITE:
            return 2;
        default://  www . j  a  va2  s. c  o m
            throw new RuntimeException("Unknown permission");
        }
    }
}

Related

  1. getPosixPermissions(int fileMode)
  2. getPosixPermissionsAsInt( Set permissionSet)
  3. givePerm(File f, Set perms)
  4. givePerms(File f, Set perms, boolean recursive)
  5. intFilePermissions(Set permissions)
  6. posixFilePermissions(int mode)
  7. setPermissionsToFile(File f, Collection perms)
  8. toOctalFileMode(Set permissions)
  9. toUnixFileMode(Set perms)