/**
  * Actually change the mode for the file.
  *
  * @param PhingFile $file
  * @param string    $user
  * @param string    $group
  *
  * @throws BuildException
  * @throws Exception
  */
 private function chownFile(PhingFile $file, $user, $group = "")
 {
     if (!$file->exists()) {
         throw new BuildException("The file " . $file->__toString() . " does not exist");
     }
     try {
         if (!empty($user)) {
             $file->setUser($user);
         }
         if (!empty($group)) {
             $file->setGroup($group);
         }
         if ($this->verbose) {
             $this->log("Changed file owner on '" . $file->__toString() . "' to " . $user . ($group ? "." . $group : ""));
         }
     } catch (Exception $e) {
         if ($this->failonerror) {
             throw $e;
         } else {
             $this->log($e->getMessage(), $this->quiet ? Project::MSG_VERBOSE : Project::MSG_WARN);
         }
     }
 }