Skip to content

Commit

Permalink
Hotfix
Browse files Browse the repository at this point in the history
  • Loading branch information
localzet committed Nov 20, 2023
1 parent 698ad8c commit 2aadc7c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions support/helpers/dirs.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function copy_dir(string $source, string $dest, bool $overwrite = false): void
if (!is_dir($dest)) {
mkdir($dest);
}
$files = array_slice(scandir($source, SCANDIR_SORT_NONE), 2);
$files = array_diff(scandir($source), ['.', '..']) ?: [];
foreach ($files as $file) {
copy_dir("$source/$file", "$dest/$file");
}
Expand All @@ -33,7 +33,7 @@ function scan_dir(string $basePath, bool $withBasePath = true): array
if (!is_dir($basePath)) {
return [];
}
$paths = array_slice(scandir($basePath, SCANDIR_SORT_NONE), 2);
$paths = array_diff(scandir($basePath), ['.', '..']) ?: [];
return $withBasePath ? array_map(fn($path) => $basePath . DIRECTORY_SEPARATOR . $path, $paths) : $paths;
}

Expand All @@ -47,7 +47,7 @@ function remove_dir(string $dir): bool
if (is_link($dir) || is_file($dir)) {
return file_exists($dir) && unlink($dir);
}
$files = array_slice(scandir($dir, SCANDIR_SORT_NONE), 2);
$files = array_diff(scandir($dir), ['.', '..']) ?: [];
foreach ($files as $file) {
$path = $dir . DIRECTORY_SEPARATOR . $file;
is_dir($path) && !is_link($path) ? remove_dir($path) : file_exists($path) && unlink($path);
Expand Down

0 comments on commit 2aadc7c

Please sign in to comment.