hinotify
Haskell binding to inotify
https://github.com/kolmodin/hinotify.git
Version on this page: | 0.3.10@rev:1 |
LTS Haskell 22.19: | 0.4.1 |
Stackage Nightly 2024-05-04: | 0.4.1 |
Latest on Hackage: | 0.4.1 |
hinotify-0.3.10@sha256:440ca08ac39ae6f4694c29a17db5afe322accfe60ba490e5047cc4b973b1e01f,2703
Module documentation for 0.3.10
- System
hinotify: inotify for Haskell
About
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.
News
hinotify 0.3.7
- Bug fix: When registerering a new watch on a path which is already watched, don’t overwrite the event listener from the previous watch.
hinotify 0.3.2
- Make each
WatchDescriptor
contain itsINotify
. Changes to the function types:
-removeWatch :: INotify -> WatchDescriptor -> IO () +removeWatch :: WatchDescriptor -> IO ()
- Fix typo in declaration of
Deleted
indata Event
;
- { isDirecotry :: Bool + { isDirectory :: Bool
hinotify 0.3.1
- Use
inotify.h
fromglibc
rather than from the linux headers, as recommended upstream.
hinotify 0.3
- Compiles with GHC 6.12, GHC 6.10.4, GHC 6.8.2 and GHC 6.6.1
hinotify 0.2
- Updates to the API
- Function names is now in semiCamelCase
- Restructure event parameters to make it more consistent
- Small test suit in
tests/
- Compiles with GHC 6.8.2 and GHC 6.6.1
- Requires Cabal 1.2
hinotify 0.1 : Initial release
API
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 :: 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 wd
Download
The code is available via the homepage, and via darcs:
git clone https://github.com/kolmodin/hinotify.git
The API is available online.
I’m most grateful for feedback on the API, and what else you might have to suggest.
Author
Lennart Kolmodin
kolmodin at gmail.com
Legal
This software is released under a BSD-style license. See LICENSE for more details.
Copyright © 2007-2012 Lennart Kolmodin
Changes
hinotify
hinotify-0.3.10
-
Allow async-2.2.
-
Use
RawFilePath
(ByteString
) for filenames, fromunix
package.Changes the
Event
type andaddWatch
function.
hinotify-0.3.9
Patches contributed by Simon Marlow [email protected]
-
Don’t run callbacks in
mask_
.It prevented the callback threads from receiving StackOverflow, amongst other things.
-
Synchronous
killThread
.killThread
will now wait for the callback dispatcher threads to finish. -
Bug fixes
hinotify-0.3.8
-
Use file system encoding for file names.
When run in a locale like LANG=C, this ensures that the filename is encoded as a filename, so that arbitrary bytes in it will round-trip correctly, rather than being stripped out.
Fixes https://github.com/kolmodin/hinotify/issues/13
Patch contributed by Joey Hess [email protected]