blob: d3e507024e683c3907a6d98830b7d7f21ee6e70f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
use v6.d.PREVIEW; unit module MaildirIndexer::ScanDir; sub scan-dir(IO() $path --> Supply) is export { supply { my %watched-dirs; sub add-dir(IO::Path $dir, :$initial) { %watched-dirs{$dir} = True; CATCH { when X::IO::Dir { }; default { .perl.say } } whenever $dir.watch { my $path-io = .path.IO; emit $path-io; when $path-io.e && $path-io.d { add-dir($path-io) unless %watched-dirs{$path-io}; } when !$path-io.e { %watched-dirs{$path-io}:delete } } for $dir.dir { emit $_; when .e && .d { add-dir($_); } } } add-dir($path); } }
|