]> _ Git - cubist_util.git/commitdiff
wip #5184 @0.25
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 29 Mar 2022 12:21:11 +0000 (14:21 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 29 Mar 2022 12:21:11 +0000 (14:21 +0200)
src/Files/Files.php

index 83bc7344d7fa8a8e50806bd9f9e386fda1f6b6cf..5ebdaad2c8e2bb2e523ec44bfd85cb496a5123ec 100644 (file)
@@ -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