aboutsummaryrefslogtreecommitdiff
path: root/src/F2Md/Utils.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/F2Md/Utils.hs')
-rw-r--r--src/F2Md/Utils.hs12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/F2Md/Utils.hs b/src/F2Md/Utils.hs
new file mode 100644
index 0000000..149730e
--- /dev/null
+++ b/src/F2Md/Utils.hs
@@ -0,0 +1,12 @@
+module F2Md.Utils (expandPath) where
+
+import System.Directory
+import System.Posix.User
+
+expandPath :: FilePath -> IO FilePath
+expandPath path =
+ let (pre, post) = break (=='/') path in
+ case pre of
+ "~" -> (++ post) <$> getHomeDirectory
+ '~' : user -> (++ post) <$> homeDirectory <$> getUserEntryForName user
+ _ -> return path