@@ -112,6 +112,7 @@ module Streamly.Internal.FileSystem.Event.Linux
112 , Event(..)
112 , Event(..)
113 , getRoot
113 , getRoot
114 , getRelPath
114 , getRelPath
115 , getCookie
116 , getCookie
117 -- ** Exception Conditions
118 -- ** Exception Conditions
@@ -172,6 +173,7 @@ import Streamly.Prelude (SerialT)
172import Streamly.Internal.Data.Parser (Parser)
173import Streamly.Internal.Data.Parser (Parser)
173import Streamly.Internal.Data.Array.Storable.Foreign.Types (Array(..))
174import Streamly.Internal.Data.Array.Storable.Foreign.Types (Array(..))
174import System.IO (Handle, hClose, IOMode(ReadMode))
175import System.IO (Handle, hClose, IOMode(ReadMode))
176+import System.IO.Unsafe (unsafePerformIO)
175#if !MIN_VERSION_base(4,10,0)
177#if !MIN_VERSION_base(4,10,0)
176import Control.Concurrent.MVar (readMVar)
178import Control.Concurrent.MVar (readMVar)
177import Data.Typeable (cast)
179import Data.Typeable (cast)
@@ -949,6 +951,21 @@ getRoot Event{..} =
949getRelPath :: Event -> Array Word8
951getRelPath :: Event -> Array Word8
950getRelPath Event{..} = eventRelPath
952getRelPath Event{..} = eventRelPath
955+-- | Get the absolute file system object path for which the event is generated.
956+-- The path is a "/" separated array of bytes.
960+getAbsPath :: Event -> Array Word8
961+getAbsPath ev0 = go ev0
965+ go ev = unsafePerformIO
967+ $ (A.toStream (getRoot ev) <> A.toStream (getRelPath ev))
952-- XXX should we use a Maybe?
969-- XXX should we use a Maybe?
953-- | Cookie is set when a rename occurs. The cookie value can be used to
970-- | Cookie is set when a rename occurs. The cookie value can be used to
954-- connect the 'isMovedFrom' and 'isMovedTo' events, if both the events belong
971-- connect the 'isMovedFrom' and 'isMovedTo' events, if both the events belong
@@ -1188,7 +1205,8 @@ showEvent ev@Event{..} =
1188 "--------------------------"
1205 "--------------------------"
1189 ++ "\nWd = " ++ show eventWd
1206 ++ "\nWd = " ++ show eventWd
1190 ++ "\nRoot = " ++ show (utf8ToString $ getRoot ev)
1207 ++ "\nRoot = " ++ show (utf8ToString $ getRoot ev)
1191− ++ "\nPath = " ++ show (utf8ToString $ getRelPath ev)
1208+ ++ "\nRelative Path = " ++ show (utf8ToString $ getRelPath ev)
1209+ ++ "\nAbsolute Path = " ++ show (utf8ToString $ getAbsPath ev)
1192 ++ "\nCookie = " ++ show (getCookie ev)
1210 ++ "\nCookie = " ++ show (getCookie ev)
1193 ++ "\nFlags " ++ show eventFlags
1211 ++ "\nFlags " ++ show eventFlags