1 ! Copyright (C) 2008 Slava Pestov.
\r
2 ! See http://factorcode.org/license.txt for BSD license.
\r
3 USING: alien.c-types alien.syntax math math.bitwise classes.struct ;
\r
4 IN: unix.linux.inotify
\r
6 STRUCT: inotify-event
\r
13 CONSTANT: IN_ACCESS HEX: 1 ! File was accessed
\r
14 CONSTANT: IN_MODIFY HEX: 2 ! File was modified
\r
15 CONSTANT: IN_ATTRIB HEX: 4 ! Metadata changed
\r
16 CONSTANT: IN_CLOSE_WRITE HEX: 8 ! Writtable file was closed
\r
17 CONSTANT: IN_CLOSE_NOWRITE HEX: 10 ! Unwrittable file closed
\r
18 CONSTANT: IN_OPEN HEX: 20 ! File was opened
\r
19 CONSTANT: IN_MOVED_FROM HEX: 40 ! File was moved from X
\r
20 CONSTANT: IN_MOVED_TO HEX: 80 ! File was moved to Y
\r
21 CONSTANT: IN_CREATE HEX: 100 ! Subfile was created
\r
22 CONSTANT: IN_DELETE HEX: 200 ! Subfile was deleted
\r
23 CONSTANT: IN_DELETE_SELF HEX: 400 ! Self was deleted
\r
24 CONSTANT: IN_MOVE_SELF HEX: 800 ! Self was moved
\r
26 CONSTANT: IN_UNMOUNT HEX: 2000 ! Backing fs was unmounted
\r
27 CONSTANT: IN_Q_OVERFLOW HEX: 4000 ! Event queued overflowed
\r
28 CONSTANT: IN_IGNORED HEX: 8000 ! File was ignored
\r
30 : IN_CLOSE ( -- n ) { IN_CLOSE_WRITE IN_CLOSE_NOWRITE } flags ; foldable ! close
\r
31 : IN_MOVE ( -- n ) { IN_MOVED_FROM IN_MOVED_TO } flags ; foldable ! moves
\r
33 CONSTANT: IN_ONLYDIR HEX: 1000000 ! only watch the path if it is a directory
\r
34 CONSTANT: IN_DONT_FOLLOW HEX: 2000000 ! don't follow a sym link
\r
35 CONSTANT: IN_MASK_ADD HEX: 20000000 ! add to the mask of an already existing watch
\r
36 CONSTANT: IN_ISDIR HEX: 40000000 ! event occurred against dir
\r
37 CONSTANT: IN_ONESHOT HEX: 80000000 ! only send event once
\r
39 : IN_CHANGE_EVENTS ( -- n )
\r
41 IN_MODIFY IN_ATTRIB IN_MOVED_FROM
\r
42 IN_MOVED_TO IN_DELETE IN_CREATE IN_DELETE_SELF
\r
46 : IN_ALL_EVENTS ( -- n )
\r
48 IN_ACCESS IN_MODIFY IN_ATTRIB IN_CLOSE_WRITE
\r
49 IN_CLOSE_NOWRITE IN_OPEN IN_MOVED_FROM
\r
50 IN_MOVED_TO IN_DELETE IN_CREATE IN_DELETE_SELF
\r
54 FUNCTION: int inotify_init ( ) ;
\r
55 FUNCTION: int inotify_add_watch ( int fd, c-string name, uint mask ) ;
\r
56 FUNCTION: int inotify_rm_watch ( int fd, uint wd ) ;
\r