Skip to content

Commit

Permalink
Update Dir.php
Browse files Browse the repository at this point in the history
  • Loading branch information
iskrisis committed Apr 27, 2023
1 parent d49be98 commit de631c8
Showing 1 changed file with 1 addition and 34 deletions.
35 changes: 1 addition & 34 deletions src/Dir.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
class Dir extends \Kirby\Toolkit\Dir {

// changed from dir class because it had .htacess in it
public static $ignore = [
public static array $ignore = [
'.',
'..',
'.DS_Store',
Expand Down Expand Up @@ -39,37 +39,4 @@ public static function read(string $dir, array $ignore = null, bool $absolute =

return $result;
}

public static function copy(string $dir, string $target, bool $recursive = true, array $ignore = []): bool
{
if (is_dir($dir) === false) {
throw new Exception('The directory "' . $dir . '" does not exist');
}

if (is_dir($target) === true) {
throw new Exception('The target directory "' . $target . '" exists');
}

if (static::make($target) !== true) {
throw new Exception('The target directory "' . $target . '" could not be created');
}

foreach (self::read($dir) as $name) {
$root = $dir . '/' . $name;

if (in_array($root, $ignore) === true) {
continue;
}

if (is_dir($root) === true) {
if ($recursive === true) {
self::copy($root, $target . '/' . $name, true, $ignore);
}
} else {
\Kirby\Toolkit\F::copy($root, $target . '/' . $name);
}
}

return true;
}
}

0 comments on commit de631c8

Please sign in to comment.