diff options
author | Yuchen Pei <hi@ypei.me> | 2022-05-27 18:57:24 +1000 |
---|---|---|
committer | Yuchen Pei <hi@ypei.me> | 2022-05-27 18:57:24 +1000 |
commit | caf354c7e5bcb5142d8b4358824d22d3de122f34 (patch) | |
tree | 7e19673f611424f4b6c44ee5316aad94aab2371a /src/F2Md/Utils.hs | |
parent | 44a5cd797d72003f580f18871d9e70c06afeb13b (diff) |
break apart the code, timestamp read imp.
Diffstat (limited to 'src/F2Md/Utils.hs')
-rw-r--r-- | src/F2Md/Utils.hs | 12 |
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 |