From 42be9e7da6aa1bf5255afb18715f5c704d7f6cb7 Mon Sep 17 00:00:00 2001 From: codewithvk Date: Sat, 11 Jan 2025 23:36:30 +0530 Subject: [PATCH] SimpleFS: Add getFullDirectoryListing for complete directory listing - Adds getFullDirectoryListing to list both files and folders. - Keeps getDirectoryListing for files only. Signed-off-by: codewithvk --- lib/private/Files/SimpleFS/SimpleFolder.php | 15 +++++++++++++++ lib/public/Files/SimpleFS/ISimpleFolder.php | 8 ++++++++ 2 files changed, 23 insertions(+) diff --git a/lib/private/Files/SimpleFS/SimpleFolder.php b/lib/private/Files/SimpleFS/SimpleFolder.php index 0da552e402b72..41fdd2b1bf2ff 100644 --- a/lib/private/Files/SimpleFS/SimpleFolder.php +++ b/lib/private/Files/SimpleFS/SimpleFolder.php @@ -44,6 +44,21 @@ public function getDirectoryListing(): array { return array_values($fileListing); } + public function getFullDirectoryListing(): array { + $listing = $this->folder->getDirectoryListing(); + + $nodeListing = array_map(function (Node $node) { + if ($node instanceof File) { + return new SimpleFile($node); + } elseif ($node instanceof Folder) { + return new SimpleFolder($node); + } + return null; + }, $listing); + + return array_values(array_filter($nodeListing)); + } + public function delete(): void { $this->folder->delete(); } diff --git a/lib/public/Files/SimpleFS/ISimpleFolder.php b/lib/public/Files/SimpleFS/ISimpleFolder.php index 79b9fca1dac2e..9bfef3d90b45a 100644 --- a/lib/public/Files/SimpleFS/ISimpleFolder.php +++ b/lib/public/Files/SimpleFS/ISimpleFolder.php @@ -22,6 +22,14 @@ interface ISimpleFolder { */ public function getDirectoryListing(): array; + /** + * Get all the files and folders in a folder + * + * @return (ISimpleFile[] || ISimpleFolder[]) + * @since 30.0.5 + */ + public function getFullDirectoryListing(): array; + /** * Check if a file with $name exists *