get rid of __WINDOWS__, use mingw32_HOST_OS
The latter is harder for me to remember, but avoids build failures in code used by the configure program.
This commit is contained in:
parent
022c3910e9
commit
93f2371e09
24 changed files with 55 additions and 55 deletions
|
@ -88,6 +88,6 @@ rawMode ch = do
|
|||
where
|
||||
raw h = do
|
||||
fileEncoding h
|
||||
#ifdef __WINDOWS__
|
||||
#ifdef mingw32_HOST_OS
|
||||
hSetNewlineMode h noNewlineTranslation
|
||||
#endif
|
||||
|
|
|
@ -36,7 +36,7 @@ copyFileExternal src dest = do
|
|||
{- Create a hard link if the filesystem allows it, and fall back to copying
|
||||
- the file. -}
|
||||
createLinkOrCopy :: FilePath -> FilePath -> IO Bool
|
||||
#ifndef __WINDOWS__
|
||||
#ifndef mingw32_HOST_OS
|
||||
createLinkOrCopy src dest = go `catchIO` const fallback
|
||||
where
|
||||
go = do
|
||||
|
|
|
@ -12,7 +12,7 @@ module Utility.Daemon where
|
|||
import Common
|
||||
import Utility.LogFile
|
||||
|
||||
#ifndef __WINDOWS__
|
||||
#ifndef mingw32_HOST_OS
|
||||
import System.Posix
|
||||
#else
|
||||
import System.PosixCompat
|
||||
|
@ -26,7 +26,7 @@ import System.Posix.Types
|
|||
-
|
||||
- When successful, does not return. -}
|
||||
daemonize :: Fd -> Maybe FilePath -> Bool -> IO () -> IO ()
|
||||
#ifndef __WINDOWS__
|
||||
#ifndef mingw32_HOST_OS
|
||||
daemonize logfd pidfile changedirectory a = do
|
||||
maybe noop checkalreadyrunning pidfile
|
||||
_ <- forkProcess child1
|
||||
|
@ -58,7 +58,7 @@ daemonize = error "daemonize is not implemented on Windows" -- TODO
|
|||
lockPidFile :: FilePath -> IO ()
|
||||
lockPidFile file = do
|
||||
createDirectoryIfMissing True (parentDir file)
|
||||
#ifndef __WINDOWS__
|
||||
#ifndef mingw32_HOST_OS
|
||||
fd <- openFd file ReadWrite (Just stdFileMode) defaultFileFlags
|
||||
locked <- catchMaybeIO $ setLock fd (WriteLock, AbsoluteSeek, 0, 0)
|
||||
fd' <- openFd newfile ReadWrite (Just stdFileMode) defaultFileFlags
|
||||
|
@ -85,7 +85,7 @@ alreadyRunning = error "Daemon is already running."
|
|||
-
|
||||
- If it's running, returns its pid. -}
|
||||
checkDaemon :: FilePath -> IO (Maybe ProcessID)
|
||||
#ifndef __WINDOWS__
|
||||
#ifndef mingw32_HOST_OS
|
||||
checkDaemon pidfile = do
|
||||
v <- catchMaybeIO $
|
||||
openFd pidfile ReadOnly (Just stdFileMode) defaultFileFlags
|
||||
|
@ -110,7 +110,7 @@ checkDaemon pidfile = maybe Nothing readish <$> catchMaybeIO (readFile pidfile)
|
|||
|
||||
{- Stops the daemon, safely. -}
|
||||
stopDaemon :: FilePath -> IO ()
|
||||
#ifndef __WINDOWS__
|
||||
#ifndef mingw32_HOST_OS
|
||||
stopDaemon pidfile = go =<< checkDaemon pidfile
|
||||
where
|
||||
go Nothing = noop
|
||||
|
|
|
@ -13,7 +13,7 @@ import Common
|
|||
|
||||
import Control.Exception (bracket)
|
||||
import System.PosixCompat.Types
|
||||
#ifndef __WINDOWS__
|
||||
#ifndef mingw32_HOST_OS
|
||||
import System.Posix.Files
|
||||
#endif
|
||||
import Foreign (complement)
|
||||
|
@ -76,7 +76,7 @@ checkMode checkfor mode = checkfor `intersectFileModes` mode == checkfor
|
|||
|
||||
{- Checks if a file mode indicates it's a symlink. -}
|
||||
isSymLink :: FileMode -> Bool
|
||||
#ifdef __WINDOWS__
|
||||
#ifdef mingw32_HOST_OS
|
||||
isSymLink _ = False
|
||||
#else
|
||||
isSymLink = checkMode symbolicLinkMode
|
||||
|
@ -89,7 +89,7 @@ isExecutable mode = combineModes executeModes `intersectFileModes` mode /= 0
|
|||
{- Runs an action without that pesky umask influencing it, unless the
|
||||
- passed FileMode is the standard one. -}
|
||||
noUmask :: FileMode -> IO a -> IO a
|
||||
#ifndef __WINDOWS__
|
||||
#ifndef mingw32_HOST_OS
|
||||
noUmask mode a
|
||||
| mode == stdFileMode = a
|
||||
| otherwise = bracket setup cleanup go
|
||||
|
@ -107,7 +107,7 @@ combineModes [m] = m
|
|||
combineModes (m:ms) = foldl unionFileModes m ms
|
||||
|
||||
isSticky :: FileMode -> Bool
|
||||
#ifdef __WINDOWS__
|
||||
#ifdef mingw32_HOST_OS
|
||||
isSticky _ = False
|
||||
#else
|
||||
isSticky = checkMode stickyMode
|
||||
|
|
|
@ -29,7 +29,7 @@ gpgcmd = fromMaybe "gpg" SysConfig.gpg
|
|||
|
||||
stdParams :: [CommandParam] -> IO [String]
|
||||
stdParams params = do
|
||||
#ifndef __WINDOWS__
|
||||
#ifndef mingw32_HOST_OS
|
||||
-- Enable batch mode if GPG_AGENT_INFO is set, to avoid extraneous
|
||||
-- gpg output about password prompts. GPG_BATCH is set by the test
|
||||
-- suite for a similar reason.
|
||||
|
@ -77,7 +77,7 @@ pipeStrict params input = do
|
|||
- Note that to avoid deadlock with the cleanup stage,
|
||||
- the reader must fully consume gpg's input before returning. -}
|
||||
feedRead :: [CommandParam] -> String -> (Handle -> IO ()) -> (Handle -> IO a) -> IO a
|
||||
#ifndef __WINDOWS__
|
||||
#ifndef mingw32_HOST_OS
|
||||
feedRead params passphrase feeder reader = do
|
||||
-- pipe the passphrase into gpg on a fd
|
||||
(frompipe, topipe) <- createPipe
|
||||
|
|
|
@ -14,7 +14,7 @@ import Common
|
|||
import System.Posix.Types
|
||||
|
||||
openLog :: FilePath -> IO Fd
|
||||
#ifndef __WINDOWS__
|
||||
#ifndef mingw32_HOST_OS
|
||||
openLog logfile = do
|
||||
rotateLog logfile
|
||||
openFd logfile WriteOnly (Just stdFileMode)
|
||||
|
@ -50,7 +50,7 @@ maxLogs :: Int
|
|||
maxLogs = 9
|
||||
|
||||
redirLog :: Fd -> IO ()
|
||||
#ifndef __WINDOWS__
|
||||
#ifndef mingw32_HOST_OS
|
||||
redirLog logfd = do
|
||||
mapM_ (redir logfd) [stdOutput, stdError]
|
||||
closeFd logfd
|
||||
|
@ -58,7 +58,7 @@ redirLog logfd = do
|
|||
redirLog _ = error "redirLog TODO"
|
||||
#endif
|
||||
|
||||
#ifndef __WINDOWS__
|
||||
#ifndef mingw32_HOST_OS
|
||||
redir :: Fd -> Fd -> IO ()
|
||||
redir newh h = do
|
||||
closeFd h
|
||||
|
|
|
@ -16,7 +16,7 @@ import Data.List
|
|||
import Data.Maybe
|
||||
import Control.Applicative
|
||||
|
||||
#ifdef __WINDOWS__
|
||||
#ifdef mingw32_HOST_OS
|
||||
import Data.Char
|
||||
import qualified System.FilePath.Posix as Posix
|
||||
#else
|
||||
|
@ -38,7 +38,7 @@ import Utility.UserInfo
|
|||
- no normalization is done.
|
||||
-}
|
||||
absNormPath :: FilePath -> FilePath -> Maybe FilePath
|
||||
#ifndef __WINDOWS__
|
||||
#ifndef mingw32_HOST_OS
|
||||
absNormPath dir path = MissingH.absNormPath dir path
|
||||
#else
|
||||
absNormPath dir path = Just $ combine dir path
|
||||
|
@ -183,7 +183,7 @@ searchPath command
|
|||
where
|
||||
indir d = check $ d </> command
|
||||
check f = firstM doesFileExist
|
||||
#ifdef __WINDOWS__
|
||||
#ifdef mingw32_HOST_OS
|
||||
[f, f ++ ".exe"]
|
||||
#else
|
||||
[f]
|
||||
|
@ -203,7 +203,7 @@ dotfile file
|
|||
{- Converts a DOS style path to a Cygwin style path. Only on Windows.
|
||||
- Any trailing '\' is preserved as a trailing '/' -}
|
||||
toCygPath :: FilePath -> FilePath
|
||||
#ifndef __WINDOWS__
|
||||
#ifndef mingw32_HOST_OS
|
||||
toCygPath = id
|
||||
#else
|
||||
toCygPath p
|
||||
|
@ -226,7 +226,7 @@ toCygPath p
|
|||
- limit.
|
||||
-}
|
||||
fileNameLengthLimit :: FilePath -> IO Int
|
||||
#ifdef __WINDOWS__
|
||||
#ifdef mingw32_HOST_OS
|
||||
fileNameLengthLimit _ = return 255
|
||||
#else
|
||||
fileNameLengthLimit dir = do
|
||||
|
|
|
@ -13,7 +13,7 @@ module Utility.ThreadScheduler where
|
|||
import Common
|
||||
|
||||
import Control.Concurrent
|
||||
#ifndef __WINDOWS__
|
||||
#ifndef mingw32_HOST_OS
|
||||
import System.Posix.Signals
|
||||
#ifndef __ANDROID__
|
||||
import System.Posix.Terminal
|
||||
|
@ -54,7 +54,7 @@ unboundDelay time = do
|
|||
waitForTermination :: IO ()
|
||||
waitForTermination = do
|
||||
lock <- newEmptyMVar
|
||||
#ifndef __WINDOWS__
|
||||
#ifndef mingw32_HOST_OS
|
||||
let check sig = void $
|
||||
installHandler sig (CatchOnce $ putMVar lock ()) Nothing
|
||||
check softwareTermination
|
||||
|
|
|
@ -24,7 +24,7 @@ import Utility.Env
|
|||
myHomeDir :: IO FilePath
|
||||
myHomeDir = myVal env homeDirectory
|
||||
where
|
||||
#ifndef __WINDOWS__
|
||||
#ifndef mingw32_HOST_OS
|
||||
env = ["HOME"]
|
||||
#else
|
||||
env = ["USERPROFILE", "HOME"] -- HOME is used in Cygwin
|
||||
|
@ -34,7 +34,7 @@ myHomeDir = myVal env homeDirectory
|
|||
myUserName :: IO String
|
||||
myUserName = myVal env userName
|
||||
where
|
||||
#ifndef __WINDOWS__
|
||||
#ifndef mingw32_HOST_OS
|
||||
env = ["USER", "LOGNAME"]
|
||||
#else
|
||||
env = ["USERNAME", "USER", "LOGNAME"]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue