@@ -112,6 +112,7 @@ module Streamly.Internal.FileSystem.Event.Linux
112112 , Event(..)
113113 , getRoot
114114 , getRelPath
115+ , getAbsPath
115116 , getCookie
116117
117118 -- ** Exception Conditions
@@ -172,6 +173,7 @@ import Streamly.Prelude (SerialT)
172173import Streamly.Internal.Data.Parser (Parser)
173174import Streamly.Internal.Data.Array.Storable.Foreign.Types (Array(..))
174175import System.IO (Handle, hClose, IOMode(ReadMode))
176+import System.IO.Unsafe (unsafePerformIO)
175177#if !MIN_VERSION_base(4,10,0)
176178import Control.Concurrent.MVar (readMVar)
177179import Data.Typeable (cast)
@@ -949,6 +951,21 @@ getRoot Event{..} =
949951getRelPath :: Event -> Array Word8
950952getRelPath Event{..} = eventRelPath
951953
954+
955+-- | Get the absolute file system object path for which the event is generated.
956+-- The path is a "/" separated array of bytes.
957+--
958+-- /Internal/
959+--
960+getAbsPath :: Event -> Array Word8
961+getAbsPath ev0 = go ev0
962+
963+ where
964+
965+ go ev = unsafePerformIO
966+ $ A.fromStream
967+ $ (A.toStream (getRoot ev) <> A.toStream (getRelPath ev))
968+
952969-- XXX should we use a Maybe?
953970-- | Cookie is set when a rename occurs. The cookie value can be used to
954971-- connect the 'isMovedFrom' and 'isMovedTo' events, if both the events belong
@@ -1188,7 +1205,8 @@ showEvent ev@Event{..} =
11881205 "--------------------------"
11891206 ++ "\nWd = " ++ show eventWd
11901207 ++ "\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)
11921210 ++ "\nCookie = " ++ show (getCookie ev)
11931211 ++ "\nFlags " ++ show eventFlags
11941212