Back to Path class

Method canChmod

public static bool
canChmod
(mixed $path)
Checks if a path's permissions can be changed.
Parameters
  • string $path Path to check.
Returns
  • bool True if path can have mode changed.
Since
  • 1.7.0
Class: Path
Project: Joomla

Method canChmod - Source code

/**
 * Checks if a path's permissions can be changed.
 *
 * @param   string  $path  Path to check.
 *
 * @return  boolean  True if path can have mode changed.
 *
 * @since   1.7.0
 */
public static function canChmod($path)
{
    $perms = fileperms($path);
    if ($perms !== false) {
        if (@chmod($path, $perms ^ 01)) {
            @chmod($path, $perms);
            return true;
        }
    }
    return false;
}