Exemplo n.º 1
0
        FileSystemRights CreateSystemRightsFile(FileSystemPermission permission)
        {
            var fileSystemRights = FileSystemRights.Synchronize;

            if (permission.HasFlag(FileSystemPermission.Read))
            {
                fileSystemRights |= FileSystemRights.Read;
            }

            if (permission.HasFlag(FileSystemPermission.Write))
            {
                fileSystemRights |= FileSystemRights.Write;
            }

            if (permission.HasFlag(FileSystemPermission.Execute))
            {
                fileSystemRights |= FileSystemRights.ExecuteFile;
            }

            return(fileSystemRights);
        }
Exemplo n.º 2
0
        static int GetPermissionBits(FileSystemPermission permission, FileSystemGroup @group)
        {
            var permissionBits = 0;

            if (permission.HasFlag(FileSystemPermission.Execute))
            {
                permissionBits |= (int)FilePermissions.S_IXOTH;
            }
            if (permission.HasFlag(FileSystemPermission.Read))
            {
                permissionBits |= (int)FilePermissions.S_IROTH;
            }
            if (permission.HasFlag(FileSystemPermission.Write))
            {
                permissionBits |= (int)FilePermissions.S_IWOTH;
            }

            var permissionWithGroupBits = 0;

            if (group.HasFlag(FileSystemGroup.Others))
            {
                permissionWithGroupBits |= permissionBits;
            }

            if (group.HasFlag(FileSystemGroup.Group))
            {
                permissionWithGroupBits |= permissionBits << 3;
            }

            if (group.HasFlag(FileSystemGroup.User))
            {
                permissionWithGroupBits |= permissionBits << 6;
            }

            return(permissionWithGroupBits);
        }