From: Vincent Vanwaelscappel Date: Mon, 28 Oct 2024 12:18:29 +0000 (+0100) Subject: wait #7158 @0.25 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=c00af3c0a15d20b5ee1238e01f3c274c43f1e044;p=cubist_util.git wait #7158 @0.25 --- diff --git a/src/Files/Files.php b/src/Files/Files.php index 982ecba..2cc7baa 100644 --- a/src/Files/Files.php +++ b/src/Files/Files.php @@ -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