summary refs log tree commit diff stats
path: root/lib/posix/inotify.nim
diff options
context:
space:
mode:
authorJuan Carlos <juancarlospaco@gmail.com>2020-04-01 14:39:58 -0300
committerGitHub <noreply@github.com>2020-04-01 19:39:58 +0200
commit48169847265e13d3b12d670230ad6d33a9d384cc (patch)
tree8028b0bea953b5cecefb6ba4353546b529c19bdd /lib/posix/inotify.nim
parent484548c784f69cadc1f6480a24e99183a0e6a930 (diff)
downloadNim-48169847265e13d3b12d670230ad6d33a9d384cc.tar.gz
Documentation, add more examples (#13825)
Diffstat (limited to 'lib/posix/inotify.nim')
-rw-r--r--lib/posix/inotify.nim10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/posix/inotify.nim b/lib/posix/inotify.nim
index f88e48a2d..9728b749b 100644
--- a/lib/posix/inotify.nim
+++ b/lib/posix/inotify.nim
@@ -70,3 +70,13 @@ proc inotify_add_watch*(fd: cint; name: cstring; mask: uint32): cint{.
 # Remove the watch specified by WD from the inotify instance FD.
 proc inotify_rm_watch*(fd: cint; wd: cint): cint{.cdecl,
     importc: "inotify_rm_watch", header: "<sys/inotify.h>".}
+
+
+runnableExamples:
+  when defined(linux):
+    block:
+      let inoty: cint = inotify_init()                 ## Create 1 Inotify.
+      doAssert inoty >= 0                              ## Check for errors.
+      let watchdoge: cint = inotify_add_watch(inoty, ".", IN_ALL_EVENTS) ## Add directory to watchdog.
+      doAssert watchdoge >= 0                          ## Check for errors.
+      doAssert inotify_rm_watch(inoty, watchdoge) >= 0 ## Remove directory from the watchdog