ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Linux-Inotify2/eg/event
Revision: 1.4
Committed: Tue Aug 23 02:22:23 2005 UTC (21 years ago) by root
Branch: MAIN
CVS Tags: rel-1_1, rel-1_0, rel-1_2, rel-2_2, rel-2_3, rel-2_0, rel-2_1, rel-1_01, rel-0_8, rel-1_21, rel-1_22, HEAD
Changes since 1.3: +2 -2 lines
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 root 1.1 #!/opt/bin/perl
2    
3 root 1.2 # example for Event integration
4 root 1.1
5     use Event;
6     use Linux::Inotify2;
7    
8     my $inotify = new Linux::Inotify2;
9    
10 root 1.4 Event->io (fd => $inotify->fileno, poll => 'r', cb => sub { $inotify->poll });
11 root 1.1
12 root 1.2 $inotify->watch ("/tmp", IN_ALL_EVENTS, sub {
13 root 1.1 my $e = shift;
14 root 1.4 printf "events for <%s>:%d received: %x\n", $e->fullname, $e->cookie, $e->mask;
15 root 1.1 print "$e->{w}{name} was accessed\n" if $e->IN_ACCESS;
16     print "$e->{w}{name} was modified\n" if $e->IN_MODIFY;
17     print "$e->{w}{name} is no longer mounted\n" if $e->IN_UNMOUNT;
18     print "events for $e->{w}{name} have been lost\n" if $e->IN_Q_OVERFLOW;
19     });
20    
21     Event::loop;
22