]> _ Git - cubist_util.git/commitdiff
wait #7158 @0.25
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 28 Oct 2024 12:18:29 +0000 (13:18 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 28 Oct 2024 12:18:29 +0000 (13:18 +0100)
src/Files/Files.php

index 982ecba232cdf6b05f51fb1a26fdf28f29cb3f98..2cc7baa55eba210688830ea58abaccbc70105181 100644 (file)
@@ -492,4 +492,25 @@ class Files
         move_uploaded_file($file->getPathname(), $dest);
         return $dest;
     }
+
+    public static function listFilesAndDirectories($path): array
+    {
+        $res = ['files' => [], 'directories' => []];
+        if (!file_exists($path)) {
+            return $res;
+        }
+        $dr = opendir($path);
+        while ($f = readdir($dr)) {
+            if ($f === "." || $f === ".." || $f === '.DS_Store' || $f === '__MACOSX') {
+                continue;
+            }
+            $p = $path . '/' . $f;
+            if (is_dir($p)) {
+                $res['directories'][] = $f;
+            } else if (is_file($p)) {
+                $res['files'][] = $f;
+            }
+        }
+        return $res;
+    }
 }
\ No newline at end of file