Couldn't this be omitted totally?
```
$view = \OCP\Files::getStorage('files_trashbin');
if(!$view->file_exists('files')) {
	$view->mkdir('files');
}
...
if ($dir) {
    $dirlisting = true;
    $dirContent = $view->opendir($dir);
    $i = 0;
    while($entryName = $view->readdir($dirContent)) {
...
```