public static function chown($path, $user, $group = null)
{
// don't do anything under Windows
if (FileSystem::getOsIdentifier() === self::OS_IDENTIFIER_WIN) {
return;
}
// check if the path exists
if (!file_exists($path)) {
return false;
}
// change the owner
if (chown($path, $user) === false) {
throw new \Exception(sprintf('Can\'t change owner for directory/flie %s to %s', $path, $user));
}
// check if group is given too
if (!is_null($group)) {
if (chgrp($path, $group) === false) {
throw new \Exception(sprintf('Can\'t change group for directory/flie %s to %s', $path, $group));
}
}
return true;
}