From 1dd7b00405f26b0b6d7437a04cf9f581208b9d17 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Tue, 29 Mar 2022 14:21:11 +0200 Subject: [PATCH] wip #5184 @0.25 --- src/Files/Files.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) 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 -- 2.39.5