/** * This test is our selection test that compared the file with the destfile. * * @param PhingFile $srcfile the source file * @param PhingFile $destfile the destination file * @return bool true if the files are different * * @throws BuildException */ protected function selectionTest(PhingFile $srcfile, PhingFile $destfile) { try { // if either of them is missing, they are different if ($srcfile->exists() !== $destfile->exists()) { return true; } if ($srcfile->length() !== $destfile->length()) { // different size => different files return true; } if (!$this->ignoreFileTimes) { // different dates => different files if ($destfile->lastModified() !== $srcfile->lastModified()) { return true; } } if (!$this->ignoreContents) { //here do a bulk comparison $fu = new FileUtils(); return !$fu->contentEquals($srcfile, $destfile); } } catch (IOException $e) { throw new BuildException("while comparing {$srcfile} and {$destfile}", $e); } return false; }
/** * comparison method of the interface * * @return bool if the files are equal * @throws BuildException if it all went pear-shaped */ public function evaluate() { if ($this->file1 == null || $this->file2 == null) { throw new BuildException("both file1 and file2 are required in filesmatch"); } $fu = new FileUtils(); return $fu->contentEquals($this->file1, $this->file2); }