diff options
| author | Joey Hess <joey@kitenet.net> | 2014-05-14 19:41:05 -0400 |
|---|---|---|
| committer | Joey Hess <joey@kitenet.net> | 2014-05-14 19:41:05 -0400 |
| commit | 7115d1ec162b4059b3e8e8f84bd8d5898c1db025 (patch) | |
| tree | 42c1cce54e890e1d56484794ab33129132d8fee2 /Utility/UserInfo.hs | |
| parent | ffe371a9d42cded461236e972a24a142419d7fc4 (diff) | |
moved source code to src
This is to work around OSX's brain-damange regarding filename case
insensitivity.
Avoided moving config.hs, because it's a config file. Put in a symlink to
make build work.
Diffstat (limited to 'Utility/UserInfo.hs')
| -rw-r--r-- | Utility/UserInfo.hs | 55 |
1 files changed, 0 insertions, 55 deletions
diff --git a/Utility/UserInfo.hs b/Utility/UserInfo.hs deleted file mode 100644 index 617c3e94..00000000 --- a/Utility/UserInfo.hs +++ /dev/null @@ -1,55 +0,0 @@ -{- user info - - - - Copyright 2012 Joey Hess <joey@kitenet.net> - - - - License: BSD-2-clause - -} - -{-# LANGUAGE CPP #-} - -module Utility.UserInfo ( - myHomeDir, - myUserName, - myUserGecos, -) where - -import Control.Applicative -import System.PosixCompat - -import Utility.Env - -{- Current user's home directory. - - - - getpwent will fail on LDAP or NIS, so use HOME if set. -} -myHomeDir :: IO FilePath -myHomeDir = myVal env homeDirectory - where -#ifndef mingw32_HOST_OS - env = ["HOME"] -#else - env = ["USERPROFILE", "HOME"] -- HOME is used in Cygwin -#endif - -{- Current user's user name. -} -myUserName :: IO String -myUserName = myVal env userName - where -#ifndef mingw32_HOST_OS - env = ["USER", "LOGNAME"] -#else - env = ["USERNAME", "USER", "LOGNAME"] -#endif - -myUserGecos :: IO String -#ifdef __ANDROID__ -myUserGecos = return "" -- userGecos crashes on Android -#else -myUserGecos = myVal [] userGecos -#endif - -myVal :: [String] -> (UserEntry -> String) -> IO String -myVal envvars extract = maybe (extract <$> getpwent) return =<< check envvars - where - check [] = return Nothing - check (v:vs) = maybe (check vs) (return . Just) =<< getEnv v - getpwent = getUserEntryForID =<< getEffectiveUserID |
