fixup #if 0 stubs to use #ifndef mingw32_HOST_OS

That's needed in files used to build the configure program.
For the other files, I'm keeping my __WINDOWS__ define, as I find that much easier to type.
I may search and replace it to use the mingw32_HOST_OS thing later.
This commit is contained in:
Joey Hess 2013-05-10 16:57:21 -05:00
parent 6c74a42cc6
commit 763cbda14f
23 changed files with 48 additions and 48 deletions

View file

@ -24,7 +24,7 @@ module Annex.Branch (
) where ) where
import qualified Data.ByteString.Lazy.Char8 as L import qualified Data.ByteString.Lazy.Char8 as L
#if 0 #ifndef mingw32_HOST_OS
import System.Posix.Env import System.Posix.Env
#endif #endif

View file

@ -13,7 +13,7 @@ import Common.Annex
import Utility.UserInfo import Utility.UserInfo
import qualified Git.Config import qualified Git.Config
#if 0 #ifndef mingw32_HOST_OS
import System.Posix.Env import System.Posix.Env
#endif #endif
import Network.BSD import Network.BSD

View file

@ -14,7 +14,7 @@ module Annex.Ssh (
) where ) where
import qualified Data.Map as M import qualified Data.Map as M
#if 0 #ifndef mingw32_HOST_OS
import System.Posix.Env import System.Posix.Env
#endif #endif

View file

@ -22,7 +22,7 @@ import Assistant.Install.Menu
import Control.Applicative import Control.Applicative
import System.Directory import System.Directory
import System.Environment import System.Environment
#if 0 #ifndef mingw32_HOST_OS
import System.Posix.User import System.Posix.User
import System.Posix.Files import System.Posix.Files
#endif #endif
@ -30,7 +30,7 @@ import System.FilePath
import Data.Maybe import Data.Maybe
systemwideInstall :: IO Bool systemwideInstall :: IO Bool
#if 0 #ifndef mingw32_HOST_OS
systemwideInstall = isroot <||> destdirset systemwideInstall = isroot <||> destdirset
where where
isroot = do isroot = do

View file

@ -17,7 +17,7 @@ import qualified Control.Exception as E
import qualified Data.Map as M import qualified Data.Map as M
import Control.Exception (throw) import Control.Exception (throw)
import System.Console.GetOpt import System.Console.GetOpt
#if 0 #ifndef mingw32_HOST_OS
import System.Posix.Signals import System.Posix.Signals
#endif #endif

View file

@ -30,7 +30,7 @@ import qualified Option
import Types.Key import Types.Key
import Utility.HumanTime import Utility.HumanTime
#if 0 #ifndef mingw32_HOST_OS
import System.Posix.Process (getProcessID) import System.Posix.Process (getProcessID)
#endif #endif
import Data.Time.Clock.POSIX import Data.Time.Clock.POSIX

View file

@ -16,7 +16,7 @@ import "MissingH" System.Path as X
import System.FilePath as X import System.FilePath as X
import System.Directory as X import System.Directory as X
import System.IO as X hiding (FilePath) import System.IO as X hiding (FilePath)
#if 0 #ifndef mingw32_HOST_OS
import System.Posix.Files as X import System.Posix.Files as X
import System.Posix.IO as X import System.Posix.IO as X
#endif #endif

View file

@ -17,7 +17,7 @@ import Types.Remote (RemoteConfig, RemoteConfigKey)
import Remote.Helper.Encryptable (remoteCipher, embedCreds) import Remote.Helper.Encryptable (remoteCipher, embedCreds)
import System.Environment import System.Environment
#if 0 #ifndef mingw32_HOST_OS
import System.Posix.Env (setEnv) import System.Posix.Env (setEnv)
#endif #endif
import qualified Data.ByteString.Lazy.Char8 as L import qualified Data.ByteString.Lazy.Char8 as L

2
Git.hs
View file

@ -32,7 +32,7 @@ module Git (
) where ) where
import Network.URI (uriPath, uriScheme, unEscapeString) import Network.URI (uriPath, uriScheme, unEscapeString)
#if 0 #ifndef mingw32_HOST_OS
import System.Posix.Files import System.Posix.Files
#endif #endif

View file

@ -23,7 +23,7 @@ module Git.Construct (
checkForRepo, checkForRepo,
) where ) where
#if 0 #ifndef mingw32_HOST_OS
import System.Posix.User import System.Posix.User
#endif #endif
import qualified Data.Map as M hiding (map, split) import qualified Data.Map as M hiding (map, split)

View file

@ -9,7 +9,7 @@
module Git.CurrentRepo where module Git.CurrentRepo where
#if 0 #ifndef mingw32_HOST_OS
import System.Posix.Directory (changeWorkingDirectory) import System.Posix.Directory (changeWorkingDirectory)
import System.Posix.Env (getEnv, unsetEnv) import System.Posix.Env (getEnv, unsetEnv)
#endif #endif

View file

@ -9,7 +9,7 @@
module GitAnnexShell where module GitAnnexShell where
#if 0 #ifndef mingw32_HOST_OS
import System.Posix.Env import System.Posix.Env
#endif #endif
import System.Console.GetOpt import System.Console.GetOpt

View file

@ -11,7 +11,7 @@ module Remote.Rsync (remote) where
import qualified Data.ByteString.Lazy as L import qualified Data.ByteString.Lazy as L
import qualified Data.Map as M import qualified Data.Map as M
#if 0 #ifndef mingw32_HOST_OS
import System.Posix.Process (getProcessID) import System.Posix.Process (getProcessID)
#endif #endif

View file

@ -13,7 +13,7 @@ import Test.HUnit
import Test.QuickCheck import Test.QuickCheck
import Test.QuickCheck.Test import Test.QuickCheck.Test
#if 0 #ifndef mingw32_HOST_OS
import System.Posix.Directory (changeWorkingDirectory) import System.Posix.Directory (changeWorkingDirectory)
import System.Posix.Files import System.Posix.Files
import System.Posix.Env import System.Posix.Env

View file

@ -12,7 +12,7 @@ module Utility.Daemon where
import Common import Common
import Utility.LogFile import Utility.LogFile
#if 0 #ifndef mingw32_HOST_OS
import System.Posix import System.Posix
#endif #endif

View file

@ -10,7 +10,7 @@
module Utility.Directory where module Utility.Directory where
import System.IO.Error import System.IO.Error
#if 0 #ifndef mingw32_HOST_OS
import System.Posix.Files import System.Posix.Files
#endif #endif
import System.Directory import System.Directory
@ -61,7 +61,7 @@ dirContentsRecursive' (dir:dirs) = unsafeInterleaveIO $ do
{- Moves one filename to another. {- Moves one filename to another.
- First tries a rename, but falls back to moving across devices if needed. -} - First tries a rename, but falls back to moving across devices if needed. -}
moveFile :: FilePath -> FilePath -> IO () moveFile :: FilePath -> FilePath -> IO ()
#if 0 #ifndef mingw32_HOST_OS
moveFile src dest = tryIO (rename src dest) >>= onrename moveFile src dest = tryIO (rename src dest) >>= onrename
where where
onrename (Right _) = noop onrename (Right _) = noop

View file

@ -19,7 +19,7 @@ import Foreign (complement)
{- Applies a conversion function to a file's mode. -} {- Applies a conversion function to a file's mode. -}
modifyFileMode :: FilePath -> (FileMode -> FileMode) -> IO () modifyFileMode :: FilePath -> (FileMode -> FileMode) -> IO ()
modifyFileMode f convert = void $ modifyFileMode' f convert modifyFileMode f convert = void $ modifyFileMode' f convert
#if 0 #ifndef __WINDOWS__
modifyFileMode' :: FilePath -> (FileMode -> FileMode) -> IO FileMode modifyFileMode' :: FilePath -> (FileMode -> FileMode) -> IO FileMode
modifyFileMode' f convert = do modifyFileMode' f convert = do
s <- getFileStatus f s <- getFileStatus f
@ -39,7 +39,7 @@ addModes ms m = combineModes (m:ms)
{- Removes the specified FileModes from the input mode. -} {- Removes the specified FileModes from the input mode. -}
removeModes :: [FileMode] -> FileMode -> FileMode removeModes :: [FileMode] -> FileMode -> FileMode
#if 0 #ifndef __WINDOWS__
removeModes ms m = m `intersectFileModes` complement (combineModes ms) removeModes ms m = m `intersectFileModes` complement (combineModes ms)
#else #else
removeModes = error "removeModes TODO" removeModes = error "removeModes TODO"
@ -54,21 +54,21 @@ withModifiedFileMode file convert a = bracket setup cleanup go
go _ = a go _ = a
writeModes :: [FileMode] writeModes :: [FileMode]
#if 0 #ifndef __WINDOWS__
writeModes = [ownerWriteMode, groupWriteMode, otherWriteMode] writeModes = [ownerWriteMode, groupWriteMode, otherWriteMode]
#else #else
writeModes = [] writeModes = []
#endif #endif
readModes :: [FileMode] readModes :: [FileMode]
#if 0 #ifndef __WINDOWS__
readModes = [ownerReadMode, groupReadMode, otherReadMode] readModes = [ownerReadMode, groupReadMode, otherReadMode]
#else #else
readModes = [] readModes = []
#endif #endif
executeModes :: [FileMode] executeModes :: [FileMode]
#if 0 #ifndef __WINDOWS__
executeModes = [ownerExecuteMode, groupExecuteMode, otherExecuteMode] executeModes = [ownerExecuteMode, groupExecuteMode, otherExecuteMode]
#else #else
executeModes = [] executeModes = []
@ -76,7 +76,7 @@ executeModes = []
{- Removes the write bits from a file. -} {- Removes the write bits from a file. -}
preventWrite :: FilePath -> IO () preventWrite :: FilePath -> IO ()
#if 0 #ifndef __WINDOWS__
preventWrite f = modifyFileMode f $ removeModes writeModes preventWrite f = modifyFileMode f $ removeModes writeModes
#else #else
preventWrite _ = return () preventWrite _ = return ()
@ -84,7 +84,7 @@ preventWrite _ = return ()
{- Turns a file's owner write bit back on. -} {- Turns a file's owner write bit back on. -}
allowWrite :: FilePath -> IO () allowWrite :: FilePath -> IO ()
#if 0 #ifndef __WINDOWS__
allowWrite f = modifyFileMode f $ addModes [ownerWriteMode] allowWrite f = modifyFileMode f $ addModes [ownerWriteMode]
#else #else
allowWrite _ = return () allowWrite _ = return ()
@ -92,7 +92,7 @@ allowWrite _ = return ()
{- Allows owner and group to read and write to a file. -} {- Allows owner and group to read and write to a file. -}
groupWriteRead :: FilePath -> IO () groupWriteRead :: FilePath -> IO ()
#if 0 #ifndef __WINDOWS__
groupWriteRead f = modifyFileMode f $ addModes groupWriteRead f = modifyFileMode f $ addModes
[ ownerWriteMode, groupWriteMode [ ownerWriteMode, groupWriteMode
, ownerReadMode, groupReadMode , ownerReadMode, groupReadMode
@ -101,14 +101,14 @@ groupWriteRead f = modifyFileMode f $ addModes
groupWriteRead _ = return () groupWriteRead _ = return ()
#endif #endif
#if 0 #ifndef __WINDOWS__
checkMode :: FileMode -> FileMode -> Bool checkMode :: FileMode -> FileMode -> Bool
checkMode checkfor mode = checkfor `intersectFileModes` mode == checkfor checkMode checkfor mode = checkfor `intersectFileModes` mode == checkfor
#endif #endif
{- Checks if a file mode indicates it's a symlink. -} {- Checks if a file mode indicates it's a symlink. -}
isSymLink :: FileMode -> Bool isSymLink :: FileMode -> Bool
#if 0 #ifndef __WINDOWS__
isSymLink = checkMode symbolicLinkMode isSymLink = checkMode symbolicLinkMode
#else #else
isSymLink _ = False isSymLink _ = False
@ -116,7 +116,7 @@ isSymLink _ = False
{- Checks if a file has any executable bits set. -} {- Checks if a file has any executable bits set. -}
isExecutable :: FileMode -> Bool isExecutable :: FileMode -> Bool
#if 0 #ifndef __WINDOWS__
isExecutable mode = combineModes executeModes `intersectFileModes` mode /= 0 isExecutable mode = combineModes executeModes `intersectFileModes` mode /= 0
#else #else
isExecutable _ = False isExecutable _ = False
@ -125,7 +125,7 @@ isExecutable _ = False
{- Runs an action without that pesky umask influencing it, unless the {- Runs an action without that pesky umask influencing it, unless the
- passed FileMode is the standard one. -} - passed FileMode is the standard one. -}
noUmask :: FileMode -> IO a -> IO a noUmask :: FileMode -> IO a -> IO a
#if 0 #ifndef __WINDOWS__
noUmask mode a noUmask mode a
| mode == stdFileMode = a | mode == stdFileMode = a
| otherwise = bracket setup cleanup go | otherwise = bracket setup cleanup go
@ -138,7 +138,7 @@ noUmask _ a = a
#endif #endif
combineModes :: [FileMode] -> FileMode combineModes :: [FileMode] -> FileMode
#if 0 #ifndef __WINDOWS__
combineModes [] = undefined combineModes [] = undefined
combineModes [m] = m combineModes [m] = m
combineModes (m:ms) = foldl unionFileModes m ms combineModes (m:ms) = foldl unionFileModes m ms
@ -150,7 +150,7 @@ stickyMode :: FileMode
stickyMode = 512 stickyMode = 512
isSticky :: FileMode -> Bool isSticky :: FileMode -> Bool
#if 0 #ifndef __WINDOWS__
isSticky = checkMode stickyMode isSticky = checkMode stickyMode
#else #else
isSticky _ = False isSticky _ = False
@ -166,7 +166,7 @@ setSticky f = modifyFileMode f $ addModes [stickyMode]
- as writeFile. - as writeFile.
-} -}
writeFileProtected :: FilePath -> String -> IO () writeFileProtected :: FilePath -> String -> IO ()
#if 0 #ifndef __WINDOWS__
writeFileProtected file content = do writeFileProtected file content = do
h <- openFile file WriteMode h <- openFile file WriteMode
void $ tryIO $ void $ tryIO $

View file

@ -13,7 +13,7 @@ import System.Posix.Types
import Control.Applicative import Control.Applicative
import Control.Concurrent import Control.Concurrent
import Control.Exception (bracket) import Control.Exception (bracket)
#if 0 #ifndef mingw32_HOST_OS
import System.Posix.Env (setEnv, unsetEnv, getEnv) import System.Posix.Env (setEnv, unsetEnv, getEnv)
#endif #endif
@ -216,7 +216,7 @@ keyBlock public ls = unlines
| public = "PUBLIC" | public = "PUBLIC"
| otherwise = "PRIVATE" | otherwise = "PRIVATE"
#if 0 #ifndef mingw32_HOST_OS
{- Runs an action using gpg in a test harness, in which gpg does {- Runs an action using gpg in a test harness, in which gpg does
- not use ~/.gpg/, but a directory with the test key set up to be used. -} - not use ~/.gpg/, but a directory with the test key set up to be used. -}
testHarness :: IO a -> IO a testHarness :: IO a -> IO a

View file

@ -11,7 +11,7 @@ module Utility.LogFile where
import Common import Common
#if 0 #ifndef mingw32_HOST_OS
import System.Posix import System.Posix
#endif #endif

View file

@ -15,7 +15,7 @@ import Foreign
import Data.Char import Data.Char
import Data.List import Data.List
import Control.Applicative import Control.Applicative
#if 0 #ifndef mingw32_HOST_OS
import System.Posix.Process (getAnyProcessStatus) import System.Posix.Process (getAnyProcessStatus)
#endif #endif
@ -122,7 +122,7 @@ hGetSomeString h sz = do
peekbytes :: Int -> Ptr Word8 -> IO [Word8] peekbytes :: Int -> Ptr Word8 -> IO [Word8]
peekbytes len buf = mapM (peekElemOff buf) [0..pred len] peekbytes len buf = mapM (peekElemOff buf) [0..pred len]
#if 0 #ifndef mingw32_HOST_OS
{- Reaps any zombie git processes. {- Reaps any zombie git processes.
- -
- Warning: Not thread safe. Anything that was expecting to wait - Warning: Not thread safe. Anything that was expecting to wait

View file

@ -42,7 +42,7 @@ import Control.Concurrent
import qualified Control.Exception as E import qualified Control.Exception as E
import Control.Monad import Control.Monad
import Data.Maybe import Data.Maybe
#if 0 #ifndef mingw32_HOST_OS
import System.Posix.IO import System.Posix.IO
#endif #endif
@ -158,7 +158,7 @@ createBackgroundProcess p a = a =<< createProcess p
- returns a transcript combining its stdout and stderr, and - returns a transcript combining its stdout and stderr, and
- whether it succeeded or failed. -} - whether it succeeded or failed. -}
processTranscript :: String -> [String] -> (Maybe String) -> IO (String, Bool) processTranscript :: String -> [String] -> (Maybe String) -> IO (String, Bool)
#if 0 #ifndef mingw32_HOST_OS
processTranscript cmd opts input = do processTranscript cmd opts input = do
(readf, writef) <- createPipe (readf, writef) <- createPipe
readh <- fdToHandle readf readh <- fdToHandle readf

View file

@ -11,7 +11,7 @@ module Utility.TempFile where
import Control.Exception (bracket) import Control.Exception (bracket)
import System.IO import System.IO
#if 0 #ifndef mingw32_HOST_OS
import System.Posix.Process import System.Posix.Process
#endif #endif
import System.Directory import System.Directory
@ -24,7 +24,7 @@ import System.FilePath
- then moving it into place. The temp file is stored in the same - then moving it into place. The temp file is stored in the same
- directory as the final file to avoid cross-device renames. -} - directory as the final file to avoid cross-device renames. -}
viaTmp :: (FilePath -> String -> IO ()) -> FilePath -> String -> IO () viaTmp :: (FilePath -> String -> IO ()) -> FilePath -> String -> IO ()
#if 0 #ifndef mingw32_HOST_OS
viaTmp a file content = do viaTmp a file content = do
pid <- getProcessID pid <- getProcessID
let tmpfile = file ++ ".tmp" ++ show pid let tmpfile = file ++ ".tmp" ++ show pid
@ -52,7 +52,7 @@ withTempFile template a = bracket create remove use
{- Runs an action with a temp directory, then removes the directory and {- Runs an action with a temp directory, then removes the directory and
- all its contents. -} - all its contents. -}
withTempDir :: Template -> (FilePath -> IO a) -> IO a withTempDir :: Template -> (FilePath -> IO a) -> IO a
#if 0 #ifndef mingw32_HOST_OS
withTempDir template = bracket create remove withTempDir template = bracket create remove
where where
remove = removeDirectoryRecursive remove = removeDirectoryRecursive

View file

@ -14,7 +14,7 @@ module Utility.UserInfo (
) where ) where
import Control.Applicative import Control.Applicative
#if 0 #ifndef mingw32_HOST_OS
import System.Posix.User import System.Posix.User
import System.Posix.Env import System.Posix.Env
#endif #endif
@ -23,7 +23,7 @@ import System.Posix.Env
- -
- getpwent will fail on LDAP or NIS, so use HOME if set. -} - getpwent will fail on LDAP or NIS, so use HOME if set. -}
myHomeDir :: IO FilePath myHomeDir :: IO FilePath
#if 0 #ifndef mingw32_HOST_OS
myHomeDir = myVal ["HOME"] homeDirectory myHomeDir = myVal ["HOME"] homeDirectory
#else #else
myHomeDir = error "myHomeDir TODO" myHomeDir = error "myHomeDir TODO"
@ -31,7 +31,7 @@ myHomeDir = error "myHomeDir TODO"
{- Current user's user name. -} {- Current user's user name. -}
myUserName :: IO String myUserName :: IO String
#if 0 #ifndef mingw32_HOST_OS
myUserName = myVal ["USER", "LOGNAME"] userName myUserName = myVal ["USER", "LOGNAME"] userName
#else #else
myUserName = error "myUserName TODO" myUserName = error "myUserName TODO"
@ -41,14 +41,14 @@ myUserGecos :: IO String
#ifdef __ANDROID__ #ifdef __ANDROID__
myUserGecos = return "" -- userGecos crashes on Android myUserGecos = return "" -- userGecos crashes on Android
#else #else
#if 0 #ifndef mingw32_HOST_OS
myUserGecos = myVal [] userGecos myUserGecos = myVal [] userGecos
#else #else
myUserGecos = error "myUserGecos TODO" myUserGecos = error "myUserGecos TODO"
#endif #endif
#endif #endif
#if 0 #ifndef mingw32_HOST_OS
myVal :: [String] -> (UserEntry -> String) -> IO String myVal :: [String] -> (UserEntry -> String) -> IO String
myVal envvars extract = maybe (extract <$> getpwent) return =<< check envvars myVal envvars extract = maybe (extract <$> getpwent) return =<< check envvars
where where