blob: 82c83c16cc0197f78952e64a99bf1d6ed37525b8 (
plain) (
blame)
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
definition module Inotify
from Data.Either import ::Either
from Data.Maybe import ::Maybe
// Inotify file descriptor
:: *Inotify st
// Inotify watch descriptor
:: INWatch
// Inotify event mask
:: INMask :== Int
// Inotify event
:: INEvent :== Int
// Inotify callback: event, maybe filename, state, world -> state, world
:: INCallback st :== INEvent (Maybe String) st *World -> *(st, *World)
(|-) infixl 6 :: (INMask INMask -> INMask)
/* Initialise an inotify file descriptor with some state */
inotify_init :: st -> Maybe *(Inotify st)
/* Close an inotify file descriptor and get back the state */
inotify_close :: *(Inotify st) -> st
/**
* Add a watch on some file
*
* INCallback st: the callback for events
* INMask: a mask of events to watch for
* String: the filename
* Inotify st: the inotify file descriptor
*
* Either Int INWatch: either an error code or a watch descriptor
* Inotify st: the new file descriptor
*/
inotify_add_watch :: (INCallback st) !INMask !String !*(Inotify st)
-> *(!Either Int INWatch, !*Inotify st)
/**
* Remove a watch
*
* INWatch: the watch to remove
* Inotify st: the inotify file descriptor
*
* Bool: success
* Inotify st: the new file descriptor
*/
inotify_rm_watch :: !INWatch !*(Inotify st) -> *(!Bool, !*Inotify st)
/**
* Poll an inotify file descriptor; i.e. wait for new events
*
* Maybe Int timeout in milliseconds (Nothing for no timeout)
*
* Int the number of events
*/
inotify_poll :: !(Maybe Int) !*(Inotify st) -> *(!Int, !*Inotify st)
/**
* Check for new events and call callbacks
*/
inotify_check :: !*(Inotify st) !*World -> *(!*Inotify st, !*World)
/**
* Check if an event matches a mask
*/
inotify_is_event :: INMask INEvent -> Bool
/**
* Combination of inotify_poll and inotify_check that will return only if no
* events were given when a timeout occurred.
*/
inotify_loop_with_timeout :: !(Maybe Int) !*(Inotify st) !*World
-> *(!*Inotify st, !*World)
/**
* inotify_loop_with_timeout with Nothing as timeout (will never return)
*/
inotify_loop_forever :: !*(Inotify st) !*World -> *(!*Inotify st, !*World)
/*** Begin inotify.h ***/
IN_ACCESS :== 0x00000001 // File was accessed
IN_MODIFY :== 0x00000002 // File was modified
IN_ATTRIB :== 0x00000004 // Metadata changed
IN_CLOSE_WRITE :== 0x00000008 // Writtable file was closed
IN_CLOSE_NOWRITE :== 0x00000010 // Unwrittable file closed
IN_OPEN :== 0x00000020 // File was opened
IN_MOVED_FROM :== 0x00000040 // File was moved from X
IN_MOVED_TO :== 0x00000080 // File was moved to Y
IN_CREATE :== 0x00000100 // Subfile was created
IN_DELETE :== 0x00000200 // Subfile was deleted
IN_DELETE_SELF :== 0x00000400 // Self was deleted
IN_MOVE_SELF :== 0x00000800 // Self was moved
IN_UNMOUNT :== 0x00002000 // Backing fs was unmounted
IN_Q_OVERFLOW :== 0x00004000 // Event queued overflowed
IN_IGNORED :== 0x00008000 // File was ignored
IN_CLOSE :== (IN_CLOSE_WRITE |- IN_CLOSE_NOWRITE) // close
IN_MOVE :== (IN_MOVED_FROM |- IN_MOVED_TO) // moves
IN_ONLYDIR :== 0x01000000 // only watch the path if it is a directory
IN_DONT_FOLLOW :== 0x02000000 // don't follow a sym link
IN_EXCL_UNLINK :== 0x04000000 // exclude events on unlinked objects
IN_MASK_ADD :== 0x20000000 // add to the mask of an already existing watch
IN_ISDIR :== 0x40000000 // event occurred against dir
IN_ONESHOT :== 0x80000000 // only send event once
IN_ALL_EVENTS :==
(IN_ACCESS |- IN_MODIFY |- IN_ATTRIB |- IN_CLOSE_WRITE |- IN_CLOSE_NOWRITE
|- IN_OPEN |- IN_MOVED_FROM |- IN_MOVED_TO |- IN_DELETE |- IN_CREATE |-
IN_DELETE_SELF |- IN_MOVE_SELF)
/*** End inotify.h ***/
|