From: Vincent Vanwaelscappel Date: Tue, 29 Mar 2022 12:21:11 +0000 (+0200) Subject: wip #5184 @0.25 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=1dd7b00405f26b0b6d7437a04cf9f581208b9d17;p=cubist_util.git wip #5184 @0.25 --- diff --git a/src/Files/Files.php b/src/Files/Files.php index 83bc734..5ebdaad 100644 --- a/src/Files/Files.php +++ b/src/Files/Files.php @@ -130,6 +130,24 @@ class Files return $f->getBasename($suffix); } + public static function copyFile($from, $to, $hashAlgo = false) + { + $do = true; + + if (file_exists($to) && filemtime($from) === filemtime($to)) { + if ($hashAlgo) { + $do = hash_file($hashAlgo, $from) !== hash_file($hashAlgo, $from); + } else { + $do = false; + } + } + if (!$do) { + return false; + } + copy($from, $to); + return true; + } + public static function copy($from, $to, $context = null) { @@ -252,4 +270,5 @@ class Files return $time; } + } \ No newline at end of file