1 ! Copyright (C) 2008 Slava Pestov.
\r
2 ! See http://factorcode.org/license.txt for BSD license.
\r
3 USING: alien.syntax math math.bitwise ;
\r
4 IN: unix.linux.inotify
\r
6 C-STRUCT: inotify-event
\r
7 { "int" "wd" } ! watch descriptor
\r
8 { "uint" "mask" } ! watch mask
\r
9 { "uint" "cookie" } ! cookie to synchronize two events
\r
10 { "uint" "len" } ! length (including nulls) of name
\r
11 { "char[0]" "name" } ! stub for possible name
\r
14 CONSTANT: IN_ACCESS HEX: 1 ! File was accessed
\r
15 CONSTANT: IN_MODIFY HEX: 2 ! File was modified
\r
16 CONSTANT: IN_ATTRIB HEX: 4 ! Metadata changed
\r
17 CONSTANT: IN_CLOSE_WRITE HEX: 8 ! Writtable file was closed
\r
18 CONSTANT: IN_CLOSE_NOWRITE HEX: 10 ! Unwrittable file closed
\r
19 CONSTANT: IN_OPEN HEX: 20 ! File was opened
\r
20 CONSTANT: IN_MOVED_FROM HEX: 40 ! File was moved from X
\r
21 CONSTANT: IN_MOVED_TO HEX: 80 ! File was moved to Y
\r
22 CONSTANT: IN_CREATE HEX: 100 ! Subfile was created
\r
23 CONSTANT: IN_DELETE HEX: 200 ! Subfile was deleted
\r
24 CONSTANT: IN_DELETE_SELF HEX: 400 ! Self was deleted
\r
25 CONSTANT: IN_MOVE_SELF HEX: 800 ! Self was moved
\r
27 CONSTANT: IN_UNMOUNT HEX: 2000 ! Backing fs was unmounted
\r
28 CONSTANT: IN_Q_OVERFLOW HEX: 4000 ! Event queued overflowed
\r
29 CONSTANT: IN_IGNORED HEX: 8000 ! File was ignored
\r
31 : IN_CLOSE ( -- n ) IN_CLOSE_WRITE IN_CLOSE_NOWRITE bitor ; inline ! close
\r
32 : IN_MOVE ( -- n ) IN_MOVED_FROM IN_MOVED_TO bitor ; inline ! moves
\r
34 CONSTANT: IN_ONLYDIR HEX: 1000000 ! only watch the path if it is a directory
\r
35 CONSTANT: IN_DONT_FOLLOW HEX: 2000000 ! don't follow a sym link
\r
36 CONSTANT: IN_MASK_ADD HEX: 20000000 ! add to the mask of an already existing watch
\r
37 CONSTANT: IN_ISDIR HEX: 40000000 ! event occurred against dir
\r
38 CONSTANT: IN_ONESHOT HEX: 80000000 ! only send event once
\r
40 : IN_CHANGE_EVENTS ( -- n )
\r
42 IN_MODIFY IN_ATTRIB IN_MOVED_FROM
\r
43 IN_MOVED_TO IN_DELETE IN_CREATE IN_DELETE_SELF
\r
47 : IN_ALL_EVENTS ( -- n )
\r
49 IN_ACCESS IN_MODIFY IN_ATTRIB IN_CLOSE_WRITE
\r
50 IN_CLOSE_NOWRITE IN_OPEN IN_MOVED_FROM
\r
51 IN_MOVED_TO IN_DELETE IN_CREATE IN_DELETE_SELF
\r
55 FUNCTION: int inotify_init ( ) ;
\r
56 FUNCTION: int inotify_add_watch ( int fd, char* name, uint mask ) ;
\r
57 FUNCTION: int inotify_rm_watch ( int fd, uint wd ) ;
\r