Skip to content

Commit

Permalink
Merge pull request #112 from utopia-php/fix-scandir
Browse files Browse the repository at this point in the history
Fix scandir
  • Loading branch information
abnegate authored Sep 4, 2024
2 parents 9c89ea2 + 68aec32 commit 7d355c5
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions src/Storage/Device/Local.php
Original file line number Diff line number Diff line change
Expand Up @@ -364,15 +364,13 @@ public function deletePath(string $path): bool

foreach ($files as $file) {
if (is_dir($file)) {
$this->deletePath(\ltrim($file, $this->getRoot().DIRECTORY_SEPARATOR));
$this->deletePath(\substr_replace($file, '', 0, \strlen($this->getRoot().DIRECTORY_SEPARATOR)));
} else {
$this->delete($file, true);
}
}

\rmdir($path);

return true;
return \rmdir($path);
}

/**
Expand Down Expand Up @@ -517,18 +515,18 @@ public function getPartitionTotalSpace(): float
*/
public function getFiles(string $dir, int $max = self::MAX_PAGE_SIZE, string $continuationToken = ''): array
{
if (! (\str_ends_with($dir, DIRECTORY_SEPARATOR))) {
$dir .= DIRECTORY_SEPARATOR;
}

$dir = rtrim($dir, DIRECTORY_SEPARATOR);
$files = [];

foreach (\scandir($dir) as $file) {
if ($file === '.' || $file === '..') {
continue;
}
foreach (\glob($dir.DIRECTORY_SEPARATOR.'*') as $file) {
$files[] = $file;
}

$files[] = $dir.$file;
/**
* Hidden files
*/
foreach (\glob($dir.DIRECTORY_SEPARATOR.'.[!.]*') as $file) {
$files[] = $file;
}

return $files;
Expand Down

0 comments on commit 7d355c5

Please sign in to comment.