return hash('sha256', $path . '/$$' . filesize($path) . '///' . filemtime($path));
}
- public static function copyFile($from, $to, $hashAlgo = false, $touch = true)
+ public static function copyFile($from, $to, $hashAlgo = false, $touch = true, $throwExceptionIfSourceNotExists = true)
{
$do = true;
+ if (!file_exists($from)) {
+ if ($throwExceptionIfSourceNotExists) {
+ throw new \Exception('File ' . $from . ' not found');
+ }
+ return false;
+ }
+
$frommtime = filemtime($from);
if (file_exists($to) && $frommtime === filemtime($to) && filesize($from) === filesize($to)) {
if ($hashAlgo) {
copy($from, $to);
if ($touch) {
- touch($to, $frommtime);
+ @touch($to, $frommtime);
}
return true;