Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

FFI to inotify for Common Lisp

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 README
Octocat-spinner-32 grovel.lisp
Octocat-spinner-32 inotify.asd
Octocat-spinner-32 inotify.lisp
Octocat-spinner-32 packages.lisp
README
(with-inotify (inot `((,(user-homedir-pathname) ,in-create)))
  (read-events inot))
  
blocks

 $ touch ~/file

 =>
(#S(EVENT
    :WATCH #<WATCH pathname: #P"/home/stas/" mask: (IN-CREATE)>
    :MASK (IN-CREATE)
    :COOKIE 0
    :NAME "file"))

The masks are only printed using names, the actual values are integers.

An easy way to check for multiple events:
(member (logior in-ignored in-delete-self in-move-self)
        events
        :key #'event-mask
        :test #'logtest)
 
With a timeout:

(with-inotify (inotify `(("/tmp/test" ,(logior in-modify
                                               in-close))))
  (loop for events = (read-events inotify :time-out 1)
        thereis events
        do (write-line "timed out")))
timed out
timed out

$ echo 10 >> /tmp/test

 =>
(#S(INOTIFY:EVENT
    :WATCH #<INOTIFY:WATCH
             pathname: #P"/tmp/test" mask: (IN-CLOSE-NOWRITE IN-CLOSE-WRITE
                                            IN-MODIFY)>
    :MASK (INOTIFY:IN-MODIFY)
    :COOKIE 0
    :NAME NIL)
 #S(INOTIFY:EVENT
    :WATCH #<INOTIFY:WATCH
             pathname: #P"/tmp/test" mask: (IN-CLOSE-NOWRITE IN-CLOSE-WRITE
                                            IN-MODIFY)>
    :MASK (INOTIFY:IN-CLOSE-WRITE)
    :COOKIE 0
    :NAME NIL))
Something went wrong with that request. Please try again.