MyNixOS website logo
Description

Haskell binding to inotify, using ByteString filepaths.

This library provides a wrapper to the Linux Kernel's inotify feature, allowing applications to subscribe to notifications when a file is accessed or modified. Filepaths are represented as ByteStrings.

hinotify-bytestring: inotify for Haskell using ByteString for filepaths

Build Status

About

hinotify-bytestring, 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-bytestring.

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 its INotify. Changes to the function types:
 -removeWatch :: INotify -> WatchDescriptor -> IO ()
 +removeWatch :: WatchDescriptor -> IO ()
  • Fix typo in declaration of Deleted in data Event;
 - { isDirecotry :: Bool
 + { isDirectory :: Bool

hinotify 0.3.1

  • Use inotify.h from glibc 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
         -> ByteString       -- file/directory to watch
         -> (Event -> IO ()) -- event handler
         -> IO WatchDescriptor
removeWatch :: WatchDescriptor -> IO ()

A sample program:

{-# LANGUAGE OverloadedStrings #-}

import System.Posix.Env.ByteString
import System.IO

import System.INotify

main :: IO ()
main = do
  inotify <- initINotify
  print inotify
  home <- getEnvDefault "HOME" "/home"
  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:

git clone https://github.com/hasufell/hinotify-bytestring.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.

Metadata

Version

0.3.8.1

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows