packages feed

reanimate 0.1.0.0 → 0.1.1.0

raw patch · 4 files changed

+43/−8 lines, 4 files

Files

+ posix/Reanimate/FileWatch.hs view
@@ -0,0 +1,18 @@+module Reanimate.FileWatch+  ( watchFile ) where++import Control.Concurrent+import           System.Directory++watchFile :: FilePath -> IO () -> IO ()+watchFile path handler = do+    t0 <- getModificationTime path+    forkIO $ loop t0+    return ()+  where+    loop lastModTime = do+      t1 <- getModificationTime path+      if t1 /= lastModTime+        then handler >> loop t1+        else threadDelay (10^3 * delay) >> loop lastModTime+    delay = 1000 -- pool delay in ms.
reanimate.cabal view
@@ -2,7 +2,7 @@ --  see http://haskell.org/cabal/users-guide/  name:                reanimate-version:             0.1.0.0+version:             0.1.1.0 -- synopsis: -- description: license:             PublicDomain@@ -32,6 +32,10 @@     Type:      git     Location:  git://github.com/lemmih/reanimate.git +Flag inotify+  Description: Enable file watching using linux's inotify+  Default:     True+ library   hs-source-dirs:     src   default-language:   Haskell2010@@ -48,18 +52,21 @@                       Reanimate.Misc   other-modules:      Reanimate.Svg.NamedColors                       Reanimate.Cache+                      Reanimate.FileWatch                       Paths_reanimate   build-depends:       base >=4.10 && <4.13,                        time, text, unix, filepath, process, directory,                        containers, reanimate-svg >= 0.7.0.0, xml, bytestring, lens, linear, mtl, matrix,                        JuicyPixels, attoparsec, parallel, diagrams, diagrams-svg,                        diagrams-core, diagrams-lib, diagrams-contrib,-                       svg-builder, matrices, cubicbezier, palette, hinotify, websockets,+                       svg-builder, matrices, cubicbezier, palette, websockets,                        hashable+  if flag(inotify)+    hs-source-dirs:    unix+    build-depends:     hinotify+  else+    hs-source-dirs:    posix -Flag gtk-viewer-  Description: Enable gtk-based viewer-  Default:     False  Flag server   Description: Enable rendering server
src/Reanimate/Driver.hs view
@@ -7,7 +7,7 @@ import           Network.WebSockets import           System.Directory   (findFile, listDirectory) import           System.Environment (getArgs, getProgName)-import           System.INotify     (EventVariety (..), addWatch, withINotify)+import           Reanimate.FileWatch (watchFile) import           System.IO          (BufferMode (..), hPutStrLn, hSetBuffering,                                      stderr, stdin) @@ -38,7 +38,7 @@         case mbSelf of           Nothing -> do             hPutStrLn stderr "Failed to find own source code."-          Just self -> withINotify $ \notify -> do+          Just self -> do             conn <- acceptRequest pending             slave <- newEmptyMVar             let handler = modifyMVar_ slave $ \tid -> do@@ -66,7 +66,7 @@                               loop (frame : acc)                   return tid             putStrLn "Found self. Listening."-            addWatch notify [Modify] self (const handler)+            watchFile self handler             putMVar slave =<< forkIO (return ())             let loop = do                   fps <- receiveData conn :: IO T.Text
+ unix/Reanimate/FileWatch.hs view
@@ -0,0 +1,10 @@+module Reanimate.FileWatch+  ( watchFile ) where++import           System.INotify++watchFile :: FilePath -> IO () -> IO ()+watchFile path handler = do+  notify <- initINotify+  addWatch notify [Modify] path (const handler)+  return ()