Actions

API15

JPath/getPermissions

From Joomla! Documentation

< API15:JPath
Replacement filing cabinet.png
This Namespace has been archived - Please Do Not Edit or Create Pages in this namespace. Pages contain information for a Joomla! version which is no longer supported. It exists only as a historical reference, will not be improved and its content may be incomplete.

Contents

Description

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

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

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

Examples

<CodeExamplesForm />