public function setOwner($owner, $recursive = False)
{
if (function_exists('posix_getpwnam') && function_exists('posix_getpwuid')) {
if (posix_getpwnam($owner) == False xor is_numeric($owner) && posix_getpwuid($owner) == False) {
throw new CFileException('Unable to set owner for filesystem object. User "' . $owner . '" is not found.');
}
}
if ($this->getExists()) {
$success = @chown($this->_realpath, $owner);
if ($success) {
$this->_owner = $owner;
}
if ($success && $this->getIsDir() && $recursive) {
$contents = $this->getContents(True);
foreach ($contents as $filepath) {
if (!@chown($filepath, $owner)) {
$this->addLog('Unable to set owner for "' . $filepath . '" to "' . $owner . '"');
$success = False;
}
}
}
if ($success) {
return $this;
}
}
$this->addLog('Unable to set owner for filesystem object to "' . $owner . '"');
return False;
}