| ![[ICO]](/icons/blank.gif) | Name | Last modified | Size | Description | 
|---|---|---|---|---|
| ![[PARENTDIR]](/icons/back.gif) | Parent Directory | - | ||
| ![[DIR]](/icons/folder.gif) | _darcs/ | 2010-05-12 21:30 | - | |
| ![[DIR]](/icons/folder.gif) | tests/ | 2010-05-12 21:30 | - | |
| ![[DIR]](/icons/folder.gif) | src/ | 2010-05-12 21:30 | - | |
| ![[TXT]](/icons/text.gif) | hinotify.css | 2010-05-12 21:30 | 1.4K | |
| ![[   ]](/icons/unknown.gif) | hinotify.cabal | 2010-05-12 21:30 | 1.0K | |
| ![[DIR]](/icons/folder.gif) | examples/ | 2010-05-12 21:30 | - | |
| ![[DIR]](/icons/folder.gif) | docs/ | 2010-05-12 21:30 | - | |
| ![[TXT]](/icons/text.gif) | Setup.lhs | 2010-05-12 21:30 | 72 | |
| ![[TXT]](/icons/text.gif) | README.html | 2010-05-12 21:30 | 4.5K | |
| ![[   ]](/icons/hand.right.gif) | README | 2010-05-12 21:30 | 2.5K | |
| ![[   ]](/icons/unknown.gif) | Makefile | 2010-05-12 21:30 | 92 | |
| ![[   ]](/icons/unknown.gif) | LICENSE | 2010-05-12 21:30 | 1.4K | |
| ![[   ]](/icons/unknown.gif) | ANNOUNCE | 2010-05-12 21:30 | 1.6K | |
hinotify, a library to inotify which has been part of the Linux kernel since 2.6.13.
inotify provides file system event notification, simply add a watcher to a file or directory and get an event when it is accessed or modified.
This module is named hinotify.
See example code in the examples directory, distributed with the source code.
inotify.h from glibc rather than from the linux headers, as recommended upstream.tests/The API basically consists of:
initINotify :: IO INotify
addWatch :: INotify
         -> [EventVariety]   -- different events to listen on
         -> FilePath         -- file/directory to watch
         -> (Event -> IO ()) -- event handler
         -> IO WatchDescriptor
removeWatch :: INotify -> WatchDescriptor -> IO ()
A sample program:
import System.Directory
import System.IO
import System.INotify
main :: IO ()
main = do
    inotify <- initINotify
    print inotify
    home <- getHomeDirectory
    wd <- addWatch
            inotify
            [Open,Close,Access,Modify,Move]
            home
            print
    print wd
    putStrLn "Listens to your home directory. Hit enter to terminate."
    getLine
    removeWatch inotify wd
The code is available via the homepage, and via darcs:
darcs get --partial http://haskell.org/~kolmodin/code/hinotify/
The API is available online.
I’m most grateful for feedback on the API, and what else you might have to suggest.
This software is released under a BSD-style license. See LICENSE for more details.
Copyright © 2007 Lennart Kolmodin