aboutsummaryrefslogtreecommitdiff
path: root/src/F2Md/Utils.hs
blob: 149730ebd50c1376298bb580d1216bc12da13e42 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
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