aboutsummaryrefslogtreecommitdiff
path: root/Utility/UserInfo.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <id@joeyh.name>2013-05-11 15:03:00 -0500
committerGravatar Joey Hess <id@joeyh.name>2013-05-11 15:03:00 -0500
commitd0fa82fb721cdc85438287e29a94cb796b7bc464 (patch)
tree26a2486b8e715b5937ce41679eafd42c02f2310a /Utility/UserInfo.hs
parent679eaf6077375c5d59501d12c79e0891cbdd904f (diff)
git-annex now builds on Windows (doesn't work)
Diffstat (limited to 'Utility/UserInfo.hs')
-rwxr-xr-xUtility/UserInfo.hs22
1 files changed, 4 insertions, 18 deletions
diff --git a/Utility/UserInfo.hs b/Utility/UserInfo.hs
index c0925ecb8..9781f584e 100755
--- a/Utility/UserInfo.hs
+++ b/Utility/UserInfo.hs
@@ -14,45 +14,31 @@ module Utility.UserInfo (
) where
import Control.Applicative
-#ifndef mingw32_HOST_OS
-import System.Posix.User
-import System.Posix.Env
-#endif
+import System.Posix.Types
+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
-#ifndef mingw32_HOST_OS
myHomeDir = myVal ["HOME"] homeDirectory
-#else
-myHomeDir = error "myHomeDir TODO"
-#endif
{- Current user's user name. -}
myUserName :: IO String
-#ifndef mingw32_HOST_OS
myUserName = myVal ["USER", "LOGNAME"] userName
-#else
-myUserName = error "myUserName TODO"
-#endif
myUserGecos :: IO String
#ifdef __ANDROID__
myUserGecos = return "" -- userGecos crashes on Android
#else
-#ifndef mingw32_HOST_OS
myUserGecos = myVal [] userGecos
-#else
-myUserGecos = error "myUserGecos TODO"
-#endif
#endif
-#ifndef mingw32_HOST_OS
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
-#endif