hinotify 0.3.2 → 0.3.3
raw patch · 7 files changed
+159/−395 lines, 7 filesdep ~basePVP ok
version bump matches the API change (PVP)
Dependency ranges changed: base
API changes (from Hackage documentation)
Files
- .gitignore +4/−0
- README +0/−122
- README.html +0/−247
- README.md +124/−0
- hinotify.cabal +11/−7
- src/System/INotify.hsc +19/−18
- src/System/INotify/Masks.hsc +1/−1
+ .gitignore view
@@ -0,0 +1,4 @@+dist+_darcs+tests/*.hi+tests/*.o
− README
@@ -1,122 +0,0 @@-% hinotify: inotify for Haskell-% Lennart Kolmodin <kolmodin@gmail.com>-% December 26, 2007-2011--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.--[inotify]: http://www.kernel.org/pub/linux/kernel/people/rml/inotify/--News-------**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- -> 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:-- darcs get --partial http://code.haskell.org/hinotify/--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-2011 Lennart Kolmodin--[homepage]: http://code.haskell.org/hinotify/--[API]: http://hackage.haskell.org/packages/archive/hinotify/latest/doc/html/System-INotify.html
− README.html
@@ -1,247 +0,0 @@-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">-<html xmlns="http://www.w3.org/1999/xhtml">-<head>- <title>hinotify: inotify for Haskell</title>- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />- <meta name="generator" content="pandoc" />- <meta name="author" content="Lennart Kolmodin - '+''+e+''+'');- // -->- kolmodin at gmail dot com" />- <meta name="date" content="December 26, 2007–2011" />- <link rel="stylesheet" href="hinotify.css" type="text/css" />-</head>-<body>-<h1 class="title">hinotify: inotify for Haskell</h1>-<div id="TOC"-><ul- ><li- ><a href="#about"- >About</a- ></li- ><li- ><a href="#news"- >News</a- ></li- ><li- ><a href="#api"- >API</a- ></li- ><li- ><a href="#download"- >Download</a- ></li- ><li- ><a href="#author"- >Author</a- ></li- ><li- ><a href="#legal"- >Legal</a- ></li- ></ul- ></div->-<div id="about"-><h2- ><a href="#TOC"- >About</a- ></h2- ><p- >hinotify, a library to <a href="http://www.kernel.org/pub/linux/kernel/people/rml/inotify/"- >inotify</a- > which has been part of the Linux kernel since 2.6.13.</p- ><p- >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.</p- ><p- >This module is named <code- >hinotify</code- >.</p- ><p- >See example code in the <code- >examples</code- > directory, distributed with the source code.</p- ></div-><div id="news"-><h2- ><a href="#TOC"- >News</a- ></h2- ><p- ><strong- >hinotify 0.3.2</strong- ></p- ><ul- ><li- >Make each <code- >WatchDescriptor</code- > contain its <code- >INotify</code- >. Changes to the function types:</li- ></ul- ><blockquote- ><pre- ><code- > -removeWatch :: INotify -> WatchDescriptor -> IO ()- +removeWatch :: WatchDescriptor -> IO ()-</code- ></pre- ></blockquote- ><ul- ><li- >Fix typo in declaration of <code- >Deleted</code- > in <code- >data Event</code- >;</li- ></ul- ><blockquote- ><pre- ><code- > - { isDirecotry :: Bool- + { isDirectory :: Bool-</code- ></pre- ></blockquote- ><p- ><strong- >hinotify 0.3.1</strong- ></p- ><ul- ><li- >Use <code- >inotify.h</code- > from <code- >glibc</code- > rather than from the linux headers, as recommended upstream.</li- ></ul- ><p- ><strong- >hinotify 0.3</strong- ></p- ><ul- ><li- >Compiles with GHC 6.12, GHC 6.10.4, GHC 6.8.2 and GHC 6.6.1</li- ></ul- ><p- ><strong- >hinotify 0.2</strong- ></p- ><ul- ><li- >Updates to the API<ul- ><li- >Function names is now in semiCamelCase</li- ><li- >Restructure event parameters to make it more consistent</li- ></ul- ></li- ><li- >Small test suit in <code- >tests/</code- ></li- ><li- >Compiles with GHC 6.8.2 and GHC 6.6.1</li- ><li- >Requires Cabal 1.2</li- ></ul- ><dl- ><dt- ><strong- >hinotify 0.1</strong- ></dt- ><dd- >Initial release</dd- ></dl- ></div-><div id="api"-><h2- ><a href="#TOC"- >API</a- ></h2- ><p- >The API basically consists of:</p- ><pre- ><code- >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 ()-</code- ></pre- ><p- >A sample program:</p- ><pre- ><code- >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-</code- ></pre- ></div-><div id="download"-><h2- ><a href="#TOC"- >Download</a- ></h2- ><p- >The code is available via the <a href="http://code.haskell.org/hinotify/"- >homepage</a- >, and via darcs:</p- ><pre- ><code- >darcs get --partial http://code.haskell.org/hinotify/-</code- ></pre- ><p- >The <a href="http://hackage.haskell.org/packages/archive/hinotify/latest/doc/html/System-INotify.html"- >API</a- > is available online.</p- ><p- >I’m most grateful for feedback on the API, and what else you might have to suggest.</p- ></div-><div id="author"-><h2- ><a href="#TOC"- >Author</a- ></h2- ><p- >Lennart Kolmodin</p- ><p- ><code- >kolmodin at gmail.com</code- ></p- ></div-><div id="legal"-><h2- ><a href="#TOC"- >Legal</a- ></h2- ><p- >This software is released under a BSD-style license. See LICENSE for more details.</p- ><p- >Copyright © 2007–2011 Lennart Kolmodin</p- ></div->-</body>-</html>-
+ README.md view
@@ -0,0 +1,124 @@+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.++[inotify]: http://www.kernel.org/pub/linux/kernel/people/rml/inotify/++News+----++**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:++```haskell+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:++```haskell+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++[homepage]: https://github.com/kolmodin/hinotify.git++[API]: http://hackage.haskell.org/packages/archive/hinotify/latest/doc/html/System-INotify.html
hinotify.cabal view
@@ -1,7 +1,7 @@ name: hinotify-version: 0.3.2+version: 0.3.3 build-type: Simple-synopsis: Haskell binding to INotify+synopsis: Haskell binding to inotify description: . This library provides a wrapper to the Linux Kernel's inotify feature,@@ -9,21 +9,25 @@ accessed or modified. . category: System-homepage: http://code.haskell.org/hinotify/README.html+homepage: https://github.com/kolmodin/hinotify.git license: BSD3 license-file: LICENSE author: Lennart Kolmodin maintainer: Lennart Kolmodin <kolmodin@gmail.com>-extra-source-files: README-cabal-version: >= 1.2+extra-source-files: README.md+cabal-version: >= 1.6 +source-repository head+ type: git+ location: git://github.com/kolmodin/hinotify.git+ flag split-base description: Choose the new smaller, split-up base package. library build-depends: unix if flag(split-base)- build-depends: base >= 3 && < 5, containers, directory+ build-depends: base >= 4.3.0.0 && < 5, containers, directory else build-depends: base < 3 extensions: ForeignFunctionInterface@@ -33,6 +37,6 @@ other-modules: System.INotify.Masks - ghc-options: -Wall+ ghc-options: -Wall hs-source-dirs: src
src/System/INotify.hsc view
@@ -1,9 +1,9 @@ ----------------------------------------------------------------------------- -- | -- Module : System.INotify--- Copyright : (c) Lennart Kolmodin 2006+-- Copyright : (c) Lennart Kolmodin 2006-2012 -- License : BSD3--- Maintainer : kolmodin@dtek.chalmers.se+-- Maintainer : kolmodin@gmail.com -- Stability : experimental -- Portability : hc portable, linux only --@@ -37,16 +37,14 @@ import Prelude hiding (init) import Control.Monad import Control.Concurrent-import Control.Concurrent.MVar-import Control.Exception (bracket)+import Control.Exception as E (bracket, catch, SomeException) import Data.Maybe import Data.Map (Map) import qualified Data.Map as Map import Foreign.C-import Foreign.Marshal+import Foreign.Marshal hiding (void) import Foreign.Ptr import Foreign.Storable-import System.Directory import System.IO import System.IO.Error #if __GLASGOW_HASKELL__ >= 612@@ -56,6 +54,7 @@ import GHC.Handle import System.Posix.Internals #endif+import System.Posix.Files import System.INotify.Masks @@ -187,16 +186,13 @@ addWatch :: INotify -> [EventVariety] -> FilePath -> (Event -> IO ()) -> IO WatchDescriptor addWatch inotify@(INotify _ fd em _ _) masks fp cb = do- is_dir <- doesDirectoryExist fp- when (not is_dir) $ do- file_exist <- doesFileExist fp- when (not file_exist) $ do- -- it's not a directory, and not a file...- -- it doesn't exist- ioError $ mkIOError doesNotExistErrorType- "can't watch what isn't there"- Nothing - (Just fp)+ catch_IO (void $+ (if (NoSymlink `elem` masks) then getSymbolicLinkStatus else getFileStatus)+ fp) $ \_ ->+ ioError $ mkIOError doesNotExistErrorType+ "can't watch what isn't there!"+ Nothing+ (Just fp) let mask = joinMasks (map eventVarietyToMask masks) wd <- withCString fp $ \fp_c -> throwErrnoIfMinus1 "addWatch" $@@ -213,6 +209,9 @@ modifyMVar_ em $ \em' -> return (Map.insert wd event em') return (WatchDescriptor inotify wd) where+ -- catch_IO is same as catchIOError from base >= 4.5.0.0+ catch_IO :: IO a -> (IOError -> IO a) -> IO a+ catch_IO = E.catch eventVarietyToMask ev = case ev of Access -> inAccess@@ -313,13 +312,15 @@ runHandler (_, e@QOverflow) = do -- send overflows to all handlers handlers <- readMVar em flip mapM_ (Map.elems handlers) $ \handler ->- catch (handler e) (\_ -> return ()) -- supress errors+ E.catch (handler e) ignore_failure -- supress errors runHandler (wd, event) = do handlers <- readMVar em let handlerM = Map.lookup wd handlers case handlerM of Nothing -> putStrLn "runHandler: couldn't find handler" -- impossible?- Just handler -> catch (handler event) (\_ -> return ())+ Just handler -> E.catch (handler event) ignore_failure+ ignore_failure :: SomeException -> IO ()+ ignore_failure _ = return () killINotify :: INotify -> IO () killINotify (INotify h _ _ tid1 tid2) =
src/System/INotify/Masks.hsc view
@@ -44,7 +44,7 @@ maskIsSet :: Mask -> CUInt -> Bool maskIsSet mask cuint = value mask .&. cuint > 0- + value :: Mask -> CUInt value (UserSpace i) = i value (Extra i) = i