{-# LANGUAGE ScopedTypeVariables #-}
module System.FSNotify.Polling
( createPollManager
, PollManager(..)
, FileListener(..)
) where
import Control.Concurrent
import Control.Exception
import Control.Monad (forM_)
import Data.Map (Map)
import qualified Data.Map as Map
import Data.Maybe
import Data.Time.Clock (UTCTime, getCurrentTime)
import Data.Time.Clock.POSIX
import Prelude hiding (FilePath)
import System.Directory (doesDirectoryExist)
import System.FSNotify.Listener
import System.FSNotify.Path (findFilesAndDirs, canonicalizeDirPath)
import System.FSNotify.Types
import System.FilePath
import System.PosixCompat.Files
import System.PosixCompat.Types
data EventType = AddedEvent
| ModifiedEvent
| RemovedEvent
newtype WatchKey = WatchKey ThreadId deriving (WatchKey -> WatchKey -> Bool
(WatchKey -> WatchKey -> Bool)
-> (WatchKey -> WatchKey -> Bool) -> Eq WatchKey
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: WatchKey -> WatchKey -> Bool
$c/= :: WatchKey -> WatchKey -> Bool
== :: WatchKey -> WatchKey -> Bool
$c== :: WatchKey -> WatchKey -> Bool
Eq, Eq WatchKey
Eq WatchKey
-> (WatchKey -> WatchKey -> Ordering)
-> (WatchKey -> WatchKey -> Bool)
-> (WatchKey -> WatchKey -> Bool)
-> (WatchKey -> WatchKey -> Bool)
-> (WatchKey -> WatchKey -> Bool)
-> (WatchKey -> WatchKey -> WatchKey)
-> (WatchKey -> WatchKey -> WatchKey)
-> Ord WatchKey
WatchKey -> WatchKey -> Bool
WatchKey -> WatchKey -> Ordering
WatchKey -> WatchKey -> WatchKey
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: WatchKey -> WatchKey -> WatchKey
$cmin :: WatchKey -> WatchKey -> WatchKey
max :: WatchKey -> WatchKey -> WatchKey
$cmax :: WatchKey -> WatchKey -> WatchKey
>= :: WatchKey -> WatchKey -> Bool
$c>= :: WatchKey -> WatchKey -> Bool
> :: WatchKey -> WatchKey -> Bool
$c> :: WatchKey -> WatchKey -> Bool
<= :: WatchKey -> WatchKey -> Bool
$c<= :: WatchKey -> WatchKey -> Bool
< :: WatchKey -> WatchKey -> Bool
$c< :: WatchKey -> WatchKey -> Bool
compare :: WatchKey -> WatchKey -> Ordering
$ccompare :: WatchKey -> WatchKey -> Ordering
$cp1Ord :: Eq WatchKey
Ord)
data WatchData = WatchData FilePath EventChannel
type WatchMap = Map WatchKey WatchData
newtype PollManager = PollManager (MVar WatchMap)
generateEvent :: UTCTime -> Bool -> EventType -> FilePath -> Maybe Event
generateEvent :: UTCTime -> Bool -> EventType -> FilePath -> Maybe Event
generateEvent UTCTime
timestamp Bool
isDir EventType
AddedEvent FilePath
filePath = Event -> Maybe Event
forall a. a -> Maybe a
Just (FilePath -> UTCTime -> Bool -> Event
Added FilePath
filePath UTCTime
timestamp Bool
isDir)
generateEvent UTCTime
timestamp Bool
isDir EventType
ModifiedEvent FilePath
filePath = Event -> Maybe Event
forall a. a -> Maybe a
Just (FilePath -> UTCTime -> Bool -> Event
Modified FilePath
filePath UTCTime
timestamp Bool
isDir)
generateEvent UTCTime
timestamp Bool
isDir EventType
RemovedEvent FilePath
filePath = Event -> Maybe Event
forall a. a -> Maybe a
Just (FilePath -> UTCTime -> Bool -> Event
Removed FilePath
filePath UTCTime
timestamp Bool
isDir)
generateEvents :: UTCTime -> EventType -> [(FilePath, Bool)] -> [Event]
generateEvents :: UTCTime -> EventType -> [(FilePath, Bool)] -> [Event]
generateEvents UTCTime
timestamp EventType
eventType = ((FilePath, Bool) -> Maybe Event) -> [(FilePath, Bool)] -> [Event]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe (\(FilePath
path, Bool
isDir) -> UTCTime -> Bool -> EventType -> FilePath -> Maybe Event
generateEvent UTCTime
timestamp Bool
isDir EventType
eventType FilePath
path)
handleEvent :: EventChannel -> ActionPredicate -> Event -> IO ()
handleEvent :: EventChannel -> ActionPredicate -> Event -> IO ()
handleEvent EventChannel
_ ActionPredicate
_ (Modified FilePath
_ UTCTime
_ Bool
True) = () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
handleEvent EventChannel
chan ActionPredicate
actPred Event
event
| ActionPredicate
actPred Event
event = EventChannel -> Event -> IO ()
forall a. Chan a -> a -> IO ()
writeChan EventChannel
chan Event
event
| Bool
otherwise = () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
pathModMap :: Bool -> FilePath -> IO (Map FilePath (UTCTime, Bool))
pathModMap :: Bool -> FilePath -> IO (Map FilePath (UTCTime, Bool))
pathModMap Bool
recursive FilePath
path = Bool -> FilePath -> IO [FilePath]
findFilesAndDirs Bool
recursive FilePath
path IO [FilePath]
-> ([FilePath] -> IO (Map FilePath (UTCTime, Bool)))
-> IO (Map FilePath (UTCTime, Bool))
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= [FilePath] -> IO (Map FilePath (UTCTime, Bool))
pathModMap'
where
pathModMap' :: [FilePath] -> IO (Map FilePath (UTCTime, Bool))
pathModMap' :: [FilePath] -> IO (Map FilePath (UTCTime, Bool))
pathModMap' [FilePath]
files = ([(FilePath, (UTCTime, Bool))] -> Map FilePath (UTCTime, Bool)
forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList ([(FilePath, (UTCTime, Bool))] -> Map FilePath (UTCTime, Bool))
-> ([Maybe (FilePath, (UTCTime, Bool))]
-> [(FilePath, (UTCTime, Bool))])
-> [Maybe (FilePath, (UTCTime, Bool))]
-> Map FilePath (UTCTime, Bool)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Maybe (FilePath, (UTCTime, Bool))]
-> [(FilePath, (UTCTime, Bool))]
forall a. [Maybe a] -> [a]
catMaybes) ([Maybe (FilePath, (UTCTime, Bool))]
-> Map FilePath (UTCTime, Bool))
-> IO [Maybe (FilePath, (UTCTime, Bool))]
-> IO (Map FilePath (UTCTime, Bool))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (FilePath -> IO (Maybe (FilePath, (UTCTime, Bool))))
-> [FilePath] -> IO [Maybe (FilePath, (UTCTime, Bool))]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM FilePath -> IO (Maybe (FilePath, (UTCTime, Bool)))
pathAndInfo [FilePath]
files
pathAndInfo :: FilePath -> IO (Maybe (FilePath, (UTCTime, Bool)))
pathAndInfo :: FilePath -> IO (Maybe (FilePath, (UTCTime, Bool)))
pathAndInfo FilePath
path = (IOException -> IO (Maybe (FilePath, (UTCTime, Bool))))
-> IO (Maybe (FilePath, (UTCTime, Bool)))
-> IO (Maybe (FilePath, (UTCTime, Bool)))
forall e a. Exception e => (e -> IO a) -> IO a -> IO a
handle (\(IOException
_ :: IOException) -> Maybe (FilePath, (UTCTime, Bool))
-> IO (Maybe (FilePath, (UTCTime, Bool)))
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe (FilePath, (UTCTime, Bool))
forall a. Maybe a
Nothing) (IO (Maybe (FilePath, (UTCTime, Bool)))
-> IO (Maybe (FilePath, (UTCTime, Bool))))
-> IO (Maybe (FilePath, (UTCTime, Bool)))
-> IO (Maybe (FilePath, (UTCTime, Bool)))
forall a b. (a -> b) -> a -> b
$ do
UTCTime
modTime <- FilePath -> IO UTCTime
getModificationTime FilePath
path
Bool
isDir <- FilePath -> IO Bool
doesDirectoryExist FilePath
path
Maybe (FilePath, (UTCTime, Bool))
-> IO (Maybe (FilePath, (UTCTime, Bool)))
forall (m :: * -> *) a. Monad m => a -> m a
return (Maybe (FilePath, (UTCTime, Bool))
-> IO (Maybe (FilePath, (UTCTime, Bool))))
-> Maybe (FilePath, (UTCTime, Bool))
-> IO (Maybe (FilePath, (UTCTime, Bool)))
forall a b. (a -> b) -> a -> b
$ (FilePath, (UTCTime, Bool)) -> Maybe (FilePath, (UTCTime, Bool))
forall a. a -> Maybe a
Just (FilePath
path, (UTCTime
modTime, Bool
isDir))
pollPath :: Int -> Bool -> EventChannel -> FilePath -> ActionPredicate -> Map FilePath (UTCTime, Bool) -> IO ()
pollPath :: Int
-> Bool
-> EventChannel
-> FilePath
-> ActionPredicate
-> Map FilePath (UTCTime, Bool)
-> IO ()
pollPath Int
interval Bool
recursive EventChannel
chan FilePath
filePath ActionPredicate
actPred Map FilePath (UTCTime, Bool)
oldPathMap = do
Int -> IO ()
threadDelay Int
interval
Maybe (Map FilePath (UTCTime, Bool))
maybeNewPathMap <- (IOException -> IO (Maybe (Map FilePath (UTCTime, Bool))))
-> IO (Maybe (Map FilePath (UTCTime, Bool)))
-> IO (Maybe (Map FilePath (UTCTime, Bool)))
forall e a. Exception e => (e -> IO a) -> IO a -> IO a
handle (\(IOException
_ :: IOException) -> Maybe (Map FilePath (UTCTime, Bool))
-> IO (Maybe (Map FilePath (UTCTime, Bool)))
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe (Map FilePath (UTCTime, Bool))
forall a. Maybe a
Nothing) (Map FilePath (UTCTime, Bool)
-> Maybe (Map FilePath (UTCTime, Bool))
forall a. a -> Maybe a
Just (Map FilePath (UTCTime, Bool)
-> Maybe (Map FilePath (UTCTime, Bool)))
-> IO (Map FilePath (UTCTime, Bool))
-> IO (Maybe (Map FilePath (UTCTime, Bool)))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Bool -> FilePath -> IO (Map FilePath (UTCTime, Bool))
pathModMap Bool
recursive FilePath
filePath)
case Maybe (Map FilePath (UTCTime, Bool))
maybeNewPathMap of
Maybe (Map FilePath (UTCTime, Bool))
Nothing -> Int
-> Bool
-> EventChannel
-> FilePath
-> ActionPredicate
-> Map FilePath (UTCTime, Bool)
-> IO ()
pollPath Int
interval Bool
recursive EventChannel
chan FilePath
filePath ActionPredicate
actPred Map FilePath (UTCTime, Bool)
oldPathMap
Just Map FilePath (UTCTime, Bool)
newPathMap -> do
UTCTime
currentTime <- IO UTCTime
getCurrentTime
let deletedMap :: Map FilePath (UTCTime, Bool)
deletedMap = Map FilePath (UTCTime, Bool)
-> Map FilePath (UTCTime, Bool) -> Map FilePath (UTCTime, Bool)
forall k a b. Ord k => Map k a -> Map k b -> Map k a
Map.difference Map FilePath (UTCTime, Bool)
oldPathMap Map FilePath (UTCTime, Bool)
newPathMap
createdMap :: Map FilePath (UTCTime, Bool)
createdMap = Map FilePath (UTCTime, Bool)
-> Map FilePath (UTCTime, Bool) -> Map FilePath (UTCTime, Bool)
forall k a b. Ord k => Map k a -> Map k b -> Map k a
Map.difference Map FilePath (UTCTime, Bool)
newPathMap Map FilePath (UTCTime, Bool)
oldPathMap
modifiedAndCreatedMap :: Map FilePath (UTCTime, Bool)
modifiedAndCreatedMap = ((UTCTime, Bool) -> (UTCTime, Bool) -> Maybe (UTCTime, Bool))
-> Map FilePath (UTCTime, Bool)
-> Map FilePath (UTCTime, Bool)
-> Map FilePath (UTCTime, Bool)
forall k a b.
Ord k =>
(a -> b -> Maybe a) -> Map k a -> Map k b -> Map k a
Map.differenceWith (UTCTime, Bool) -> (UTCTime, Bool) -> Maybe (UTCTime, Bool)
modifiedDifference Map FilePath (UTCTime, Bool)
newPathMap Map FilePath (UTCTime, Bool)
oldPathMap
modifiedMap :: Map FilePath (UTCTime, Bool)
modifiedMap = Map FilePath (UTCTime, Bool)
-> Map FilePath (UTCTime, Bool) -> Map FilePath (UTCTime, Bool)
forall k a b. Ord k => Map k a -> Map k b -> Map k a
Map.difference Map FilePath (UTCTime, Bool)
modifiedAndCreatedMap Map FilePath (UTCTime, Bool)
createdMap
generateEvents' :: EventType -> [(FilePath, Bool)] -> [Event]
generateEvents' = UTCTime -> EventType -> [(FilePath, Bool)] -> [Event]
generateEvents UTCTime
currentTime
[Event] -> IO ()
handleEvents ([Event] -> IO ()) -> [Event] -> IO ()
forall a b. (a -> b) -> a -> b
$ EventType -> [(FilePath, Bool)] -> [Event]
generateEvents' EventType
AddedEvent [(FilePath
path, Bool
isDir) | (FilePath
path, (UTCTime
_, Bool
isDir)) <- Map FilePath (UTCTime, Bool) -> [(FilePath, (UTCTime, Bool))]
forall k a. Map k a -> [(k, a)]
Map.toList Map FilePath (UTCTime, Bool)
createdMap]
[Event] -> IO ()
handleEvents ([Event] -> IO ()) -> [Event] -> IO ()
forall a b. (a -> b) -> a -> b
$ EventType -> [(FilePath, Bool)] -> [Event]
generateEvents' EventType
ModifiedEvent [(FilePath
path, Bool
isDir) | (FilePath
path, (UTCTime
_, Bool
isDir)) <- Map FilePath (UTCTime, Bool) -> [(FilePath, (UTCTime, Bool))]
forall k a. Map k a -> [(k, a)]
Map.toList Map FilePath (UTCTime, Bool)
modifiedMap]
[Event] -> IO ()
handleEvents ([Event] -> IO ()) -> [Event] -> IO ()
forall a b. (a -> b) -> a -> b
$ EventType -> [(FilePath, Bool)] -> [Event]
generateEvents' EventType
RemovedEvent [(FilePath
path, Bool
isDir) | (FilePath
path, (UTCTime
_, Bool
isDir)) <- Map FilePath (UTCTime, Bool) -> [(FilePath, (UTCTime, Bool))]
forall k a. Map k a -> [(k, a)]
Map.toList Map FilePath (UTCTime, Bool)
deletedMap]
Int
-> Bool
-> EventChannel
-> FilePath
-> ActionPredicate
-> Map FilePath (UTCTime, Bool)
-> IO ()
pollPath Int
interval Bool
recursive EventChannel
chan FilePath
filePath ActionPredicate
actPred Map FilePath (UTCTime, Bool)
newPathMap
where
modifiedDifference :: (UTCTime, Bool) -> (UTCTime, Bool) -> Maybe (UTCTime, Bool)
modifiedDifference :: (UTCTime, Bool) -> (UTCTime, Bool) -> Maybe (UTCTime, Bool)
modifiedDifference (UTCTime
newTime, Bool
isDir1) (UTCTime
oldTime, Bool
isDir2)
| UTCTime
oldTime UTCTime -> UTCTime -> Bool
forall a. Eq a => a -> a -> Bool
/= UTCTime
newTime Bool -> Bool -> Bool
|| Bool
isDir1 Bool -> Bool -> Bool
forall a. Eq a => a -> a -> Bool
/= Bool
isDir2 = (UTCTime, Bool) -> Maybe (UTCTime, Bool)
forall a. a -> Maybe a
Just (UTCTime
newTime, Bool
isDir1)
| Bool
otherwise = Maybe (UTCTime, Bool)
forall a. Maybe a
Nothing
handleEvents :: [Event] -> IO ()
handleEvents :: [Event] -> IO ()
handleEvents = (Event -> IO ()) -> [Event] -> IO ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ (EventChannel -> ActionPredicate -> Event -> IO ()
handleEvent EventChannel
chan ActionPredicate
actPred)
createPollManager :: IO PollManager
createPollManager :: IO PollManager
createPollManager = MVar WatchMap -> PollManager
PollManager (MVar WatchMap -> PollManager)
-> IO (MVar WatchMap) -> IO PollManager
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> WatchMap -> IO (MVar WatchMap)
forall a. a -> IO (MVar a)
newMVar WatchMap
forall k a. Map k a
Map.empty
killWatchingThread :: WatchKey -> IO ()
killWatchingThread :: WatchKey -> IO ()
killWatchingThread (WatchKey ThreadId
threadId) = ThreadId -> IO ()
killThread ThreadId
threadId
killAndUnregister :: MVar WatchMap -> WatchKey -> IO ()
killAndUnregister :: MVar WatchMap -> WatchKey -> IO ()
killAndUnregister MVar WatchMap
mvarMap WatchKey
wk = do
WatchMap
_ <- MVar WatchMap -> (WatchMap -> IO WatchMap) -> IO WatchMap
forall a b. MVar a -> (a -> IO b) -> IO b
withMVar MVar WatchMap
mvarMap ((WatchMap -> IO WatchMap) -> IO WatchMap)
-> (WatchMap -> IO WatchMap) -> IO WatchMap
forall a b. (a -> b) -> a -> b
$ \WatchMap
m -> do
WatchKey -> IO ()
killWatchingThread WatchKey
wk
WatchMap -> IO WatchMap
forall (m :: * -> *) a. Monad m => a -> m a
return (WatchMap -> IO WatchMap) -> WatchMap -> IO WatchMap
forall a b. (a -> b) -> a -> b
$ WatchKey -> WatchMap -> WatchMap
forall k a. Ord k => k -> Map k a -> Map k a
Map.delete WatchKey
wk WatchMap
m
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
listen' :: Bool -> WatchConfig -> PollManager -> FilePath -> ActionPredicate -> EventChannel -> IO (IO ())
listen' :: Bool
-> WatchConfig
-> PollManager
-> FilePath
-> ActionPredicate
-> EventChannel
-> IO (IO ())
listen' Bool
isRecursive WatchConfig
conf (PollManager MVar WatchMap
mvarMap) FilePath
path ActionPredicate
actPred EventChannel
chan = do
FilePath
path' <- FilePath -> IO FilePath
canonicalizeDirPath FilePath
path
Map FilePath (UTCTime, Bool)
pmMap <- Bool -> FilePath -> IO (Map FilePath (UTCTime, Bool))
pathModMap Bool
isRecursive FilePath
path'
ThreadId
threadId <- IO () -> IO ThreadId
forkIO (IO () -> IO ThreadId) -> IO () -> IO ThreadId
forall a b. (a -> b) -> a -> b
$ Int
-> Bool
-> EventChannel
-> FilePath
-> ActionPredicate
-> Map FilePath (UTCTime, Bool)
-> IO ()
pollPath (WatchConfig -> Int
confPollInterval WatchConfig
conf) Bool
isRecursive EventChannel
chan FilePath
path' ActionPredicate
actPred Map FilePath (UTCTime, Bool)
pmMap
let wk :: WatchKey
wk = ThreadId -> WatchKey
WatchKey ThreadId
threadId
MVar WatchMap -> (WatchMap -> IO WatchMap) -> IO ()
forall a. MVar a -> (a -> IO a) -> IO ()
modifyMVar_ MVar WatchMap
mvarMap ((WatchMap -> IO WatchMap) -> IO ())
-> (WatchMap -> IO WatchMap) -> IO ()
forall a b. (a -> b) -> a -> b
$ WatchMap -> IO WatchMap
forall (m :: * -> *) a. Monad m => a -> m a
return (WatchMap -> IO WatchMap)
-> (WatchMap -> WatchMap) -> WatchMap -> IO WatchMap
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WatchKey -> WatchData -> WatchMap -> WatchMap
forall k a. Ord k => k -> a -> Map k a -> Map k a
Map.insert WatchKey
wk (FilePath -> EventChannel -> WatchData
WatchData FilePath
path' EventChannel
chan)
IO () -> IO (IO ())
forall (m :: * -> *) a. Monad m => a -> m a
return (IO () -> IO (IO ())) -> IO () -> IO (IO ())
forall a b. (a -> b) -> a -> b
$ MVar WatchMap -> WatchKey -> IO ()
killAndUnregister MVar WatchMap
mvarMap WatchKey
wk
instance FileListener PollManager where
initSession :: IO (Maybe PollManager)
initSession = (PollManager -> Maybe PollManager)
-> IO PollManager -> IO (Maybe PollManager)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap PollManager -> Maybe PollManager
forall a. a -> Maybe a
Just IO PollManager
createPollManager
killSession :: PollManager -> IO ()
killSession (PollManager MVar WatchMap
mvarMap) = do
WatchMap
watchMap <- MVar WatchMap -> IO WatchMap
forall a. MVar a -> IO a
readMVar MVar WatchMap
mvarMap
[WatchKey] -> (WatchKey -> IO ()) -> IO ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
t a -> (a -> m b) -> m ()
forM_ (WatchMap -> [WatchKey]
forall k a. Map k a -> [k]
Map.keys WatchMap
watchMap) WatchKey -> IO ()
killWatchingThread
listen :: WatchConfig
-> PollManager
-> FilePath
-> ActionPredicate
-> EventChannel
-> IO (IO ())
listen = Bool
-> WatchConfig
-> PollManager
-> FilePath
-> ActionPredicate
-> EventChannel
-> IO (IO ())
listen' Bool
False
listenRecursive :: WatchConfig
-> PollManager
-> FilePath
-> ActionPredicate
-> EventChannel
-> IO (IO ())
listenRecursive = Bool
-> WatchConfig
-> PollManager
-> FilePath
-> ActionPredicate
-> EventChannel
-> IO (IO ())
listen' Bool
True
usesPolling :: PollManager -> Bool
usesPolling = Bool -> PollManager -> Bool
forall a b. a -> b -> a
const Bool
True
getModificationTime :: FilePath -> IO UTCTime
getModificationTime :: FilePath -> IO UTCTime
getModificationTime FilePath
p = EpochTime -> UTCTime
fromEpoch (EpochTime -> UTCTime)
-> (FileStatus -> EpochTime) -> FileStatus -> UTCTime
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FileStatus -> EpochTime
modificationTime (FileStatus -> UTCTime) -> IO FileStatus -> IO UTCTime
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> FilePath -> IO FileStatus
getFileStatus FilePath
p
fromEpoch :: EpochTime -> UTCTime
fromEpoch :: EpochTime -> UTCTime
fromEpoch = POSIXTime -> UTCTime
posixSecondsToUTCTime (POSIXTime -> UTCTime)
-> (EpochTime -> POSIXTime) -> EpochTime -> UTCTime
forall b c a. (b -> c) -> (a -> b) -> a -> c
. EpochTime -> POSIXTime
forall a b. (Real a, Fractional b) => a -> b
realToFrac