public function getHashFile($algorithm, $path, $cache = false)
{
if ($cache == false) {
return hash_file($algorithm, $path);
} else {
$changed = false;
$cacheFile = $this->basePath . Compiler::getCurrentVersion() . DIRECTORY_SEPARATOR . str_replace(array(DIRECTORY_SEPARATOR, ':', '/'), '_', $path) . '.md5';
if (!file_exists($cacheFile)) {
$hash = hash_file($algorithm, $path);
file_put_contents($cacheFile, $hash);
$changed = true;
} else {
if (filemtime($path) > filemtime($cacheFile)) {
$hash = hash_file($algorithm, $path);
file_put_contents($cacheFile, $hash);
$changed = true;
}
}
if (!$changed) {
return file_get_contents($cacheFile);
}
return $hash;
}
}