From 19c905a33251ec20fb1227c56b6a83b607456b02 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Wed, 31 Aug 2022 20:13:51 +0200 Subject: [PATCH] wait #4209 @0.5 --- composer.json | 2 +- src/Files/Files.php | 25 ++++++++++++++++++++++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 93901ef..1354163 100644 --- a/composer.json +++ b/composer.json @@ -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" } } diff --git a/src/Files/Files.php b/src/Files/Files.php index 626b0c1..87a0f5c 100644 --- a/src/Files/Files.php +++ b/src/Files/Files.php @@ -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 -- 2.39.5