summaryrefslogtreecommitdiff
path: root/dht/Presence/ConfigFiles.hs
diff options
context:
space:
mode:
Diffstat (limited to 'dht/Presence/ConfigFiles.hs')
-rw-r--r--dht/Presence/ConfigFiles.hs12
1 files changed, 11 insertions, 1 deletions
diff --git a/dht/Presence/ConfigFiles.hs b/dht/Presence/ConfigFiles.hs
index d0164e33..e88989f2 100644
--- a/dht/Presence/ConfigFiles.hs
+++ b/dht/Presence/ConfigFiles.hs
@@ -59,7 +59,7 @@ createConfigFile :: ByteString -> FilePath -> IO ()
59createConfigFile tag path = do 59createConfigFile tag path = do
60 let dir = dropFileName path 60 let dir = dropFileName path
61 doesDirectoryExist dir >>= flip unless (do 61 doesDirectoryExist dir >>= flip unless (do
62 createDirectory dir 62 createDirectoryIfMissing True dir
63 ) 63 )
64 withFile path WriteMode $ \h -> do 64 withFile path WriteMode $ \h -> do
65 L.hPutStrLn h tag 65 L.hPutStrLn h tag
@@ -79,6 +79,16 @@ addItem item tag path =
79 in doit 79 in doit
80 80
81 81
82getProfiles :: User -> IO [Profile]
83getProfiles user = do
84 home <- homeDirectory <$> getUserEntryForName (unpack user)
85 let cfg = home </> configDir
86 fs <- listDirectory cfg
87 ds <- filterM (doesDirectoryExist . (cfg </>)) fs
88 return ds
89 `catchIOError` \e -> do
90 return []
91
82-- | Modify a presence configuration file. This function will iterate over all 92-- | Modify a presence configuration file. This function will iterate over all
83-- items in the file and invoke a test function. If the function returns 93-- items in the file and invoke a test function. If the function returns
84-- Nothing, that item is removed from the file. Otherwise, the function may 94-- Nothing, that item is removed from the file. Otherwise, the function may