API16

API16:JPath/getPermissions

From Joomla! Documentation

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