0 | module System.Linux.Inotify.Inotify
3 | import Derive.Prelude
4 | import System.Posix.File.FileDesc
5 | import System.Posix.File.ReadRes
6 | import System.Linux.Inotify.Flags
9 | %language ElabReflection
15 | %foreign "C:li_inotify_more, linux-idris"
16 | prim__inotify_more : AnyPtr -> AnyPtr -> Bits32 -> Bits32
18 | %foreign "C:li_inotify_next, linux-idris"
19 | prim__inotify_next : AnyPtr -> AnyPtr
21 | %foreign "C:li_inotify_wd, linux-idris"
22 | prim__inotify_wd : AnyPtr -> Bits32
24 | %foreign "C:li_inotify_mask, linux-idris"
25 | prim__inotify_mask : AnyPtr -> Bits32
27 | %foreign "C:li_inotify_cookie, linux-idris"
28 | prim__inotify_cookie : AnyPtr -> Bits32
36 | record Inotify where
41 | Cast Inotify Fd where cast = cast . fd
44 | Cast CInt Inotify where cast = I . cast
46 | %runElab derive "Inotify" [Show,Eq,Ord]
54 | %runElab derive "Watch" [Show,Eq,Ord]
57 | Interpolation Watch where interpolate = show . wd
60 | Cast CInt Watch where cast = W . cast
63 | Cast Watch Bits32 where cast = wd
66 | record InotifyRes where
73 | %runElab derive "InotifyRes" [Show,Eq]
76 | reslt : AnyPtr -> InotifyRes
79 | { watch = W $
prim__inotify_wd p
80 | , mask = IM $
prim__inotify_mask p
81 | , cookie = prim__inotify_cookie p
86 | results : SnocList InotifyRes -> AnyPtr -> AnyPtr -> Bits32 -> List InotifyRes
87 | results sx orig cur sz =
88 | case prim__inotify_more orig cur sz of
94 | (assert_smaller cur $
prim__inotify_next cur)
98 | FromPtr (List InotifyRes) where
99 | fromPtr (CP sz p) t = results [<] p p sz # t
102 | FromBuf (List InotifyRes) where
103 | fromBuf = viaPtrFromBuf