Actions

API16

JPath/getPermissions

< API16:JPath

The "API16" namespace is an archived namespace. This page contains information for a Joomla! version which is no longer supported. It exists only as a historical reference, it will not be improved and its content may be incomplete and/or contain broken links.

Description

Get the permissions of the file/folder at a give path



Syntax

getPermissions($path)
Parameter Name Default Value Description
$path $path The path of a file/folder

Returns

string Filesystem permissions

Defined in

libraries/joomla/filesystem/path.php

Importing

jimport( 'joomla.filesystem.path' );

Source Body

function getPermissions($path)
{
        $path = JPath::clean($path);
        $mode = @ decoct(@ fileperms($path) & 0777);
 
        if (strlen($mode) < 3) {
                return '---------';
        }
        $parsed_mode = '';
        for ($i = 0; $i < 3; $i ++)
        {
                // read
                $parsed_mode .= ($mode { $i } & 04) ? "r" : "-";
                // write
                $parsed_mode .= ($mode { $i } & 02) ? "w" : "-";
                // execute
                $parsed_mode .= ($mode { $i } & 01) ? "x" : "-";
        }
        return $parsed_mode;
}



Examples

Code Examples


Advertisement