]> _ Git - cubist_util.git/commitdiff
wait #4209 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 31 Aug 2022 18:13:51 +0000 (20:13 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 31 Aug 2022 18:13:51 +0000 (20:13 +0200)
composer.json
src/Files/Files.php

index 93901ef25a5e97a587fa884de9a37db405354a1d..1354163b96fe1bc527e7e966336bd8aef6f23fe0 100644 (file)
@@ -29,9 +29,9 @@
     "ext-simplexml": "*",
     "ext-json": "*",
     "ext-iconv": "*",
+    "ext-sodium": "*",
     "laravel/framework": "~5.8|^6.0|^7.0|^8.0",
     "cubist/net": "dev-master",
-    "ext-sodium": "*",
     "dpb587/microdata-dom": "dev-master"
   }
 }
index 626b0c12728860a167ea546e07c4b96819894f61..87a0f5c516752ffdd0a575449b6e8676ce535078 100644 (file)
@@ -74,6 +74,12 @@ class Files
         return $res;
     }
 
+    /**
+     * @param $path
+     * @param $recursive
+     * @param $recursiveMode
+     * @return \SplFileInfo[]|\DirectoryIterator|\RecursiveIteratorIterator
+     */
     public static function getDirectoryIterator($path, $recursive = false, $recursiveMode = \RecursiveIteratorIterator::SELF_FIRST)
     {
         if ($recursive) {
@@ -82,7 +88,7 @@ class Files
 
         $path = realpath($path);
         if (!file_exists($path)) {
-            return array();
+            return [];
         }
         return new  \DirectoryIterator($path);
     }
@@ -282,6 +288,23 @@ class Files
         return $time;
     }
 
+    public static function checkHashDir($dir)
+    {
+        $nb = 0;
+        $time = 0;
+        $size = 0;
+
+        $files = self::getDirectoryIterator($dir, true);
+
+        foreach ($files as $f) {
+            $time = max($time, $f->getMTime());
+            $nb++;
+            $size += $f->getSize();
+        }
+
+        return hash('sha256', $dir . '$$' . $nb . '//' . $size . '|||' . $time);
+    }
+
     /**
      * @param ...$files string
      * @return string|null