Java Posix fromPosixPermission(PosixFilePermission permission)

Here you can find the source of fromPosixPermission(PosixFilePermission permission)

Description

from Posix Permission

License

Open Source License

Declaration

private static String fromPosixPermission(PosixFilePermission permission) 

Method Source Code

//package com.java2s;
/*//from w w  w  .j ava  2  s . c o m
 * Copyright 2013-2015 EMC Corporation. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License").
 * You may not use this file except in compliance with the License.
 * A copy of the License is located at
 *
 * http://www.apache.org/licenses/LICENSE-2.0.txt
 *
 * or in the "license" file accompanying this file. This file is distributed
 * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
 * express or implied. See the License for the specific language governing
 * permissions and limitations under the License.
 */

import java.nio.file.attribute.*;

public class Main {
    public static final String READ = "READ";
    public static final String WRITE = "WRITE";
    public static final String EXECUTE = "EXECUTE";

    private static String fromPosixPermission(PosixFilePermission permission) {
        switch (permission) {
        case OWNER_READ:
        case GROUP_READ:
        case OTHERS_READ:
            return READ;
        case OWNER_WRITE:
        case GROUP_WRITE:
        case OTHERS_WRITE:
            return WRITE;
        case OWNER_EXECUTE:
        case GROUP_EXECUTE:
        case OTHERS_EXECUTE:
            return EXECUTE;
        default:
            throw new IllegalArgumentException("unknown POSIX permission: " + permission);
        }
    }
}

Related

  1. addPermissions(Set permissions, String prefix, long mode)
  2. getFileMode(Set posixPermissions)
  3. getPosixFileAttributes(@Nonnull File file)
  4. getPosixFilePermissions(int mode)
  5. getPosixPermissions(File forFile)