+{-# LANGUAGE CPP #-}
-- generic AMQP publisher
import Control.Concurrent (threadDelay)
import qualified Control.Exception as X
import Control.Monad (forever)
import qualified Data.ByteString.Lazy.Char8 as BL
+#if MIN_VERSION_hinotify(0,3,10)
+import qualified Data.ByteString.Char8 as BS
+#endif
import Data.List (isSuffixOf)
import Data.Maybe
import qualified Data.Text as T
addWatch
inotify
[CloseWrite, MoveIn]
+#if MIN_VERSION_hinotify(0,3,10)
+ (BS.pack (inputFile args))
+#else
(inputFile args)
+#endif
(handleEvent publishOneMsg (suffix args) (inputFile args))
hr $ "BEGIN watching " ++ (inputFile args)
_ <- forever $ threadDelay 1000000
-> Event
-> IO ()
-- just handle closewrite and movedin events
+#if MIN_VERSION_hinotify(0,3,10)
+handleEvent f s p (Closed False (Just x) True) = handleFile f s (p ++ "/" ++ (BS.unpack x))
+handleEvent f s p (MovedIn False x _) = handleFile f s (p ++ "/" ++ (BS.unpack x))
+#else
handleEvent f s p (Closed False (Just x) True) = handleFile f s (p ++ "/" ++ x)
handleEvent f s p (MovedIn False x _) = handleFile f s (p ++ "/" ++ x)
+#endif
handleEvent _ _ _ _ = return ()
-- | Hotfolder file handler