| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Mojo::File::ChangeNotify::WatcherProcess 0.03; |
|
2
|
8
|
|
|
8
|
|
183
|
use 5.020; |
|
|
8
|
|
|
|
|
42
|
|
|
3
|
8
|
|
|
8
|
|
68
|
use experimental 'signatures'; |
|
|
8
|
|
|
|
|
21
|
|
|
|
8
|
|
|
|
|
45
|
|
|
4
|
8
|
|
|
8
|
|
1164
|
use feature 'postderef'; |
|
|
8
|
|
|
|
|
17
|
|
|
|
8
|
|
|
|
|
278
|
|
|
5
|
8
|
|
|
8
|
|
38
|
use feature 'try'; |
|
|
8
|
|
|
|
|
21
|
|
|
|
8
|
|
|
|
|
297
|
|
|
6
|
8
|
|
|
8
|
|
42
|
use Exporter 'import'; |
|
|
8
|
|
|
|
|
15
|
|
|
|
8
|
|
|
|
|
330
|
|
|
7
|
8
|
|
|
8
|
|
4074
|
use File::ChangeNotify; |
|
|
8
|
|
|
|
|
2426851
|
|
|
|
8
|
|
|
|
|
2944
|
|
|
8
|
|
|
|
|
|
|
our @EXPORT_OK = 'watch'; |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# We keep this in a separate module file as to minimize any variables |
|
11
|
|
|
|
|
|
|
# shared over into this context |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 NAME |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Mojo::File::ChangeNotify::WatcherProcess - helper module for the subprocess |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
my $w = Mojo::File::ChangeNotify->instantiate_watcher( |
|
20
|
|
|
|
|
|
|
directories => ['.'], |
|
21
|
|
|
|
|
|
|
on_change => sub($s,$ev) { |
|
22
|
|
|
|
|
|
|
for my $e ($ev->@*) { |
|
23
|
|
|
|
|
|
|
print "$e->{type} $e->{path}\n"; |
|
24
|
|
|
|
|
|
|
} |
|
25
|
|
|
|
|
|
|
} |
|
26
|
|
|
|
|
|
|
); |
|
27
|
|
|
|
|
|
|
# note that the watcher might need about 1s to start up |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=cut |
|
30
|
|
|
|
|
|
|
|
|
31
|
0
|
|
|
0
|
0
|
|
sub watch( $subprocess, $args ) { |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
32
|
0
|
|
|
|
|
|
my $watcher = File::ChangeNotify->instantiate_watcher( $args->%* ); |
|
33
|
|
|
|
|
|
|
RESTART: |
|
34
|
0
|
|
|
|
|
|
try { |
|
35
|
|
|
|
|
|
|
# File::ChangeNotify dies when it gets an empty string back from Inotify :/ |
|
36
|
0
|
|
|
|
|
|
while( my @events = $watcher->wait_for_events ) { |
|
37
|
0
|
|
|
|
|
|
for my $list (@events) { |
|
38
|
0
|
|
|
|
|
|
$subprocess->progress( [ map {; |
|
39
|
0
|
0
|
|
|
|
|
defined $_->path |
|
40
|
|
|
|
|
|
|
? +{ path => $_->path, type => $_->type } |
|
41
|
|
|
|
|
|
|
: () |
|
42
|
|
|
|
|
|
|
} $list ]); |
|
43
|
|
|
|
|
|
|
} |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
} catch( $e ) { |
|
46
|
|
|
|
|
|
|
goto RESTART |
|
47
|
0
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
} |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
1; |