diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2015-04-04 11:14:32 +0900 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2015-04-04 11:14:32 +0900 |
commit | 7df97884eea1b19d7cef9e32b5e2787d0ea5bed7 (patch) | |
tree | 6a1e696bf9fb9c10b91dce2e24efbfbd1ee82995 | |
parent | bc9d3b102835d3c91cedc3f3e310a2c7491251a7 (diff) | |
download | srem-7df97884eea1b19d7cef9e32b5e2787d0ea5bed7.tar.gz |
re-organise
-rw-r--r-- | src/Utility/Notify/Posix.hs | 40 |
1 files changed, 23 insertions, 17 deletions
diff --git a/src/Utility/Notify/Posix.hs b/src/Utility/Notify/Posix.hs index 29c9b87..2bfac71 100644 --- a/src/Utility/Notify/Posix.hs +++ b/src/Utility/Notify/Posix.hs @@ -65,26 +65,32 @@ getDBusUserAddress :: IO (Maybe Address) getDBusUserAddress = do -- TODO: catch various IO exceptions! dir <- (</>) <$> getHomeDirectory <*> pure (".dbus" </> "session-bus") - contents <- getDirectoryContents dir - let realContents = filter (`notElem` [".", ".."]) contents - socketFile <- return realContents - >>= mapM (return . ((dir ++ "/") ++)) - >>= newestFile - + socketFile <- getNewestRealFile dir + -- let realContents = filter (`notElem` [".", ".."]) contents + -- socketFile <- return realContents + -- >>= mapM (return . ((dir ++ "/") ++)) + -- >>= newestFile addr <- readFile socketFile return (return addr >>= parseAddress) -newestFile :: [FilePath] -> IO FilePath -newestFile xs = do - modTimes <- getModTimes xs - let sorted = sortBy (compare `on` snd) modTimes - return $ (fst . head) sorted - --- expects absolute paths -getModTimes :: [FilePath] -> IO [(FilePath, UTCTime)] -getModTimes xs = do - modTimes <- foldM (\ts f -> do; modTime <- getModificationTime f; return (ts ++ [modTime])) [] xs - return $ zip xs modTimes +-- | Return the newest file in a directory, or the empty string if +-- passed a file or empty directory. +getNewestRealFile :: FilePath -> IO FilePath +getNewestRealFile dir = do + + undefined + +-- newestFile :: [FilePath] -> IO FilePath +-- newestFile xs = do +-- modTimes <- getModTimes xs +-- let sorted = sortBy (compare `on` snd) modTimes +-- return $ (fst . head) sorted + +-- -- expects absolute paths +-- getModTimes :: [FilePath] -> IO [(FilePath, UTCTime)] +-- getModTimes xs = do +-- modTimes <- foldM (\ts f -> do; modTime <- getModificationTime f; return (ts ++ [modTime])) [] xs +-- return $ zip xs modTimes -- fixDBusEnvironment :: IO () -- fixDBusEnvironment = do |