/**
* Get the permissions of the file/folder at a given path.
*
* @param string $path The path of a file/folder.
*
* @return string Filesystem permissions.
*
* @since 1.7.0
*/
public static function getPermissions($path)
{
$path = self::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;
}