fswatcher 0.1.2 → 0.1.3
raw patch · 2 files changed
+4/−3 lines, 2 files
Files
- fswatcher.cabal +1/−1
- fswatcher.hs +3/−2
fswatcher.cabal view
@@ -1,7 +1,7 @@ name: fswatcher category: Tools build-type: Simple-version: 0.1.2+version: 0.1.3 synopsis: Watch a file/directory and run a command when it's modified description: A simple program that watches a file or a directory and runs a given command whenever the file or a file within the
fswatcher.hs view
@@ -3,6 +3,7 @@ import System.Environment (getArgs, getProgName) import System.Directory (canonicalizePath, getCurrentDirectory) import Filesystem.Path ((</>), directory)+import Filesystem.Path.CurrentOS (decodeString, encodeString) import Data.String (fromString) import System.FSNotify (Event (..), StopListening, WatchManager, startManager, stopManager, watchTree, watchDir)@@ -22,8 +23,8 @@ watch :: FileType -> WatchManager -> String -> MVar () -> IO StopListening watch filetype m path trigger = let watchFun = case filetype of- Directory -> watchTree m (fromString path) (const True)- File -> watchDir m (directory $ fromString path) isThisFile+ Directory -> watchTree m path (const True)+ File -> watchDir m (encodeString $ directory $ decodeString path) isThisFile in watchFun (\_ -> void $ tryPutMVar trigger ()) where isThisFile (Modified p _) = p == fromString path