API15

JPath/getPermissions

From Joomla! Documentation

< API15:JPath
Revision as of 20:01, 24 March 2017 by JoomlaWikiBot (talk | contribs) (preparing for archive only)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

The "API15" 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[edit]

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

[<! removed edit link to red link >]

<! removed transcluded page call, red link never existed >

Syntax[edit]

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

Returns[edit]

string Filesystem permissions

Defined in[edit]

libraries/joomla/filesystem/path.php

Importing[edit]

jimport( 'joomla.filesystem.path' );

Source Body[edit]

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;
}

[<! removed edit link to red link >] <! removed transcluded page call, red link never existed >

Examples[edit]

Code Examples[edit]