Skip to content

Commit

Permalink
SimpleFS: Add getFullDirectoryListing for complete directory listing
Browse files Browse the repository at this point in the history
- Adds getFullDirectoryListing to list both files and folders.
- Keeps getDirectoryListing for files only.

Signed-off-by: codewithvk <[email protected]>
  • Loading branch information
codewithvk committed Jan 12, 2025
1 parent dfa7e7e commit 6d47475
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
15 changes: 15 additions & 0 deletions lib/private/Files/SimpleFS/SimpleFolder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
8 changes: 8 additions & 0 deletions lib/public/Files/SimpleFS/ISimpleFolder.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ interface ISimpleFolder {
*/
public function getDirectoryListing(): array;

/**
* Get all the Files and Folder in a folder
*
* @return (ISimpleFile[] || ISimpleFolder[])
* @since 30.0.5
*/
public function getFullDirectoryListing(): array;

/**
* Check if a file with $name exists
*
Expand Down

0 comments on commit 6d47475

Please sign in to comment.