function fix()
 {
     if (empty($this->_fixes)) {
         return 0;
     }
     list($files, $ids) = $this->_getFilesAndIds($this->_fixes);
     $config =& $this->getConfig();
     $filePerms = intval($config->get('permission_max_file_permission', '644'), 8);
     $dirPerms = intval($config->get('permission_max_dir_permission', '755'), 8);
     $chmoddedFiles = array();
     $rollback = false;
     @clearstatcache();
     foreach ($files as $file) {
         if (!JFile::exists($file) && !JFolder::exists($file)) {
             continue;
         }
         $info = new stdClass();
         $info->perms = fileperms($file);
         $info->file = $file;
         $isFile = is_file($file);
         $isDir = is_dir($file);
         if ($isFile || $isDir) {
             $f = new JD_File($file);
             $perms = $isFile ? $filePerms : $dirPerms;
             if ($f->chmod($perms) === false) {
                 $this->setError($f->getError());
                 $rollback = true;
                 break;
             }
         }
         $chmoddedFiles[] = $info;
     }
     if ($rollback) {
         foreach ($chmoddedFiles as $info) {
             $f = new JD_File($info->file);
             $f->chmod($info->perms);
         }
         $this->_fixes = array();
         return false;
     }
     parent::setLogStatus($ids, 'fixed');
     parent::refreshFilesystemTable($files);
     $this->_fixes = array();
     return count($chmoddedFiles);
 }