use v6.d;
class App::MediaControl::FS {
has IO::Path() $.root is required;
has $!extensions;
submethod TWEAK(:$extensions) {
$!extensions = any($extensions.Slip);
}
method get-children-of(Str $path) {
my $base = $!root.child($path);
return @() unless $base.d;
my @children = eager $base.dir(
test => -> $f {
my $based-f = $base.child($f);
$based-f.d ?? $f ~~ $*SPEC.curupdir !!
($based-f.extension ~~ $!extensions) ?? True !!
False;
},
);
return @children.map(
-> $f {
%( name => $f.basename, is_dir => $f.d );
}
).sort({ .<name> });
}
method exists(Str $path) {
return $!root.child($path).e;
}
}