本文整理匯總了PHP中FileUtils::contentEquals方法的典型用法代碼示例。如果您正苦於以下問題:PHP FileUtils::contentEquals方法的具體用法?PHP FileUtils::contentEquals怎麽用?PHP FileUtils::contentEquals使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類FileUtils
的用法示例。
在下文中一共展示了FileUtils::contentEquals方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: selectionTest
/**
* 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;
}
示例2: evaluate
/**
* 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);
}