diff options
author | 2013-05-10 16:57:21 -0500 | |
---|---|---|
committer | 2013-05-10 16:57:21 -0500 | |
commit | ae6293ae6710b0a7580bc9a0045c92d1d5b87036 (patch) | |
tree | fbd105bed124fb698fdc5bbdf4eb2d9ccd086979 /Utility | |
parent | 5d0476bf59674b39fa6bad7e4446b5c741181143 (diff) |
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.
Diffstat (limited to 'Utility')
-rwxr-xr-x | Utility/Daemon.hs | 2 | ||||
-rwxr-xr-x | Utility/Directory.hs | 4 | ||||
-rwxr-xr-x | Utility/FileMode.hs | 30 | ||||
-rwxr-xr-x | Utility/Gpg.hs | 4 | ||||
-rwxr-xr-x | Utility/LogFile.hs | 2 | ||||
-rwxr-xr-x | Utility/Misc.hs | 4 | ||||
-rwxr-xr-x | Utility/Process.hs | 4 | ||||
-rwxr-xr-x | Utility/TempFile.hs | 6 | ||||
-rwxr-xr-x | Utility/UserInfo.hs | 10 |
9 files changed, 33 insertions, 33 deletions
diff --git a/Utility/Daemon.hs b/Utility/Daemon.hs index 835b8f149..fb8c61f75 100755 --- a/Utility/Daemon.hs +++ b/Utility/Daemon.hs @@ -12,7 +12,7 @@ module Utility.Daemon where import Common import Utility.LogFile -#if 0 +#ifndef mingw32_HOST_OS import System.Posix #endif diff --git a/Utility/Directory.hs b/Utility/Directory.hs index 55d79a825..0dbba0584 100755 --- a/Utility/Directory.hs +++ b/Utility/Directory.hs @@ -10,7 +10,7 @@ module Utility.Directory where import System.IO.Error -#if 0 +#ifndef mingw32_HOST_OS import System.Posix.Files #endif import System.Directory @@ -61,7 +61,7 @@ dirContentsRecursive' (dir:dirs) = unsafeInterleaveIO $ do {- Moves one filename to another. - First tries a rename, but falls back to moving across devices if needed. -} moveFile :: FilePath -> FilePath -> IO () -#if 0 +#ifndef mingw32_HOST_OS moveFile src dest = tryIO (rename src dest) >>= onrename where onrename (Right _) = noop diff --git a/Utility/FileMode.hs b/Utility/FileMode.hs index cf9ec45a2..b4132f2ad 100755 --- a/Utility/FileMode.hs +++ b/Utility/FileMode.hs @@ -19,7 +19,7 @@ import Foreign (complement) {- Applies a conversion function to a file's mode. -} modifyFileMode :: FilePath -> (FileMode -> FileMode) -> IO () modifyFileMode f convert = void $ modifyFileMode' f convert -#if 0 +#ifndef __WINDOWS__ modifyFileMode' :: FilePath -> (FileMode -> FileMode) -> IO FileMode modifyFileMode' f convert = do s <- getFileStatus f @@ -39,7 +39,7 @@ addModes ms m = combineModes (m:ms) {- Removes the specified FileModes from the input mode. -} removeModes :: [FileMode] -> FileMode -> FileMode -#if 0 +#ifndef __WINDOWS__ removeModes ms m = m `intersectFileModes` complement (combineModes ms) #else removeModes = error "removeModes TODO" @@ -54,21 +54,21 @@ withModifiedFileMode file convert a = bracket setup cleanup go go _ = a writeModes :: [FileMode] -#if 0 +#ifndef __WINDOWS__ writeModes = [ownerWriteMode, groupWriteMode, otherWriteMode] #else writeModes = [] #endif readModes :: [FileMode] -#if 0 +#ifndef __WINDOWS__ readModes = [ownerReadMode, groupReadMode, otherReadMode] #else readModes = [] #endif executeModes :: [FileMode] -#if 0 +#ifndef __WINDOWS__ executeModes = [ownerExecuteMode, groupExecuteMode, otherExecuteMode] #else executeModes = [] @@ -76,7 +76,7 @@ executeModes = [] {- Removes the write bits from a file. -} preventWrite :: FilePath -> IO () -#if 0 +#ifndef __WINDOWS__ preventWrite f = modifyFileMode f $ removeModes writeModes #else preventWrite _ = return () @@ -84,7 +84,7 @@ preventWrite _ = return () {- Turns a file's owner write bit back on. -} allowWrite :: FilePath -> IO () -#if 0 +#ifndef __WINDOWS__ allowWrite f = modifyFileMode f $ addModes [ownerWriteMode] #else allowWrite _ = return () @@ -92,7 +92,7 @@ allowWrite _ = return () {- Allows owner and group to read and write to a file. -} groupWriteRead :: FilePath -> IO () -#if 0 +#ifndef __WINDOWS__ groupWriteRead f = modifyFileMode f $ addModes [ ownerWriteMode, groupWriteMode , ownerReadMode, groupReadMode @@ -101,14 +101,14 @@ groupWriteRead f = modifyFileMode f $ addModes groupWriteRead _ = return () #endif -#if 0 +#ifndef __WINDOWS__ checkMode :: FileMode -> FileMode -> Bool checkMode checkfor mode = checkfor `intersectFileModes` mode == checkfor #endif {- Checks if a file mode indicates it's a symlink. -} isSymLink :: FileMode -> Bool -#if 0 +#ifndef __WINDOWS__ isSymLink = checkMode symbolicLinkMode #else isSymLink _ = False @@ -116,7 +116,7 @@ isSymLink _ = False {- Checks if a file has any executable bits set. -} isExecutable :: FileMode -> Bool -#if 0 +#ifndef __WINDOWS__ isExecutable mode = combineModes executeModes `intersectFileModes` mode /= 0 #else isExecutable _ = False @@ -125,7 +125,7 @@ isExecutable _ = False {- Runs an action without that pesky umask influencing it, unless the - passed FileMode is the standard one. -} noUmask :: FileMode -> IO a -> IO a -#if 0 +#ifndef __WINDOWS__ noUmask mode a | mode == stdFileMode = a | otherwise = bracket setup cleanup go @@ -138,7 +138,7 @@ noUmask _ a = a #endif combineModes :: [FileMode] -> FileMode -#if 0 +#ifndef __WINDOWS__ combineModes [] = undefined combineModes [m] = m combineModes (m:ms) = foldl unionFileModes m ms @@ -150,7 +150,7 @@ stickyMode :: FileMode stickyMode = 512 isSticky :: FileMode -> Bool -#if 0 +#ifndef __WINDOWS__ isSticky = checkMode stickyMode #else isSticky _ = False @@ -166,7 +166,7 @@ setSticky f = modifyFileMode f $ addModes [stickyMode] - as writeFile. -} writeFileProtected :: FilePath -> String -> IO () -#if 0 +#ifndef __WINDOWS__ writeFileProtected file content = do h <- openFile file WriteMode void $ tryIO $ diff --git a/Utility/Gpg.hs b/Utility/Gpg.hs index 6fcf173b1..0ed4b85da 100755 --- a/Utility/Gpg.hs +++ b/Utility/Gpg.hs @@ -13,7 +13,7 @@ import System.Posix.Types import Control.Applicative import Control.Concurrent import Control.Exception (bracket) -#if 0 +#ifndef mingw32_HOST_OS import System.Posix.Env (setEnv, unsetEnv, getEnv) #endif @@ -216,7 +216,7 @@ keyBlock public ls = unlines | public = "PUBLIC" | otherwise = "PRIVATE" -#if 0 +#ifndef mingw32_HOST_OS {- 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. -} testHarness :: IO a -> IO a diff --git a/Utility/LogFile.hs b/Utility/LogFile.hs index d608cd798..c6faee028 100755 --- a/Utility/LogFile.hs +++ b/Utility/LogFile.hs @@ -11,7 +11,7 @@ module Utility.LogFile where import Common -#if 0 +#ifndef mingw32_HOST_OS import System.Posix #endif diff --git a/Utility/Misc.hs b/Utility/Misc.hs index 576a6ddbf..da4da0a60 100755 --- a/Utility/Misc.hs +++ b/Utility/Misc.hs @@ -15,7 +15,7 @@ import Foreign import Data.Char import Data.List import Control.Applicative -#if 0 +#ifndef mingw32_HOST_OS import System.Posix.Process (getAnyProcessStatus) #endif @@ -122,7 +122,7 @@ hGetSomeString h sz = do peekbytes :: Int -> Ptr Word8 -> IO [Word8] peekbytes len buf = mapM (peekElemOff buf) [0..pred len] -#if 0 +#ifndef mingw32_HOST_OS {- Reaps any zombie git processes. - - Warning: Not thread safe. Anything that was expecting to wait diff --git a/Utility/Process.hs b/Utility/Process.hs index 381a14983..6e0aef21c 100755 --- a/Utility/Process.hs +++ b/Utility/Process.hs @@ -42,7 +42,7 @@ import Control.Concurrent import qualified Control.Exception as E import Control.Monad import Data.Maybe -#if 0 +#ifndef mingw32_HOST_OS import System.Posix.IO #endif @@ -158,7 +158,7 @@ createBackgroundProcess p a = a =<< createProcess p - returns a transcript combining its stdout and stderr, and - whether it succeeded or failed. -} processTranscript :: String -> [String] -> (Maybe String) -> IO (String, Bool) -#if 0 +#ifndef mingw32_HOST_OS processTranscript cmd opts input = do (readf, writef) <- createPipe readh <- fdToHandle readf diff --git a/Utility/TempFile.hs b/Utility/TempFile.hs index e5617d48b..ba7449ba2 100755 --- a/Utility/TempFile.hs +++ b/Utility/TempFile.hs @@ -11,7 +11,7 @@ module Utility.TempFile where import Control.Exception (bracket) import System.IO -#if 0 +#ifndef mingw32_HOST_OS import System.Posix.Process #endif import System.Directory @@ -24,7 +24,7 @@ import System.FilePath - then moving it into place. The temp file is stored in the same - directory as the final file to avoid cross-device renames. -} viaTmp :: (FilePath -> String -> IO ()) -> FilePath -> String -> IO () -#if 0 +#ifndef mingw32_HOST_OS viaTmp a file content = do pid <- getProcessID 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 - all its contents. -} withTempDir :: Template -> (FilePath -> IO a) -> IO a -#if 0 +#ifndef mingw32_HOST_OS withTempDir template = bracket create remove where remove = removeDirectoryRecursive diff --git a/Utility/UserInfo.hs b/Utility/UserInfo.hs index 6fad3d7b4..c0925ecb8 100755 --- a/Utility/UserInfo.hs +++ b/Utility/UserInfo.hs @@ -14,7 +14,7 @@ module Utility.UserInfo ( ) where import Control.Applicative -#if 0 +#ifndef mingw32_HOST_OS import System.Posix.User import System.Posix.Env #endif @@ -23,7 +23,7 @@ import System.Posix.Env - - getpwent will fail on LDAP or NIS, so use HOME if set. -} myHomeDir :: IO FilePath -#if 0 +#ifndef mingw32_HOST_OS myHomeDir = myVal ["HOME"] homeDirectory #else myHomeDir = error "myHomeDir TODO" @@ -31,7 +31,7 @@ myHomeDir = error "myHomeDir TODO" {- Current user's user name. -} myUserName :: IO String -#if 0 +#ifndef mingw32_HOST_OS myUserName = myVal ["USER", "LOGNAME"] userName #else myUserName = error "myUserName TODO" @@ -41,14 +41,14 @@ myUserGecos :: IO String #ifdef __ANDROID__ myUserGecos = return "" -- userGecos crashes on Android #else -#if 0 +#ifndef mingw32_HOST_OS myUserGecos = myVal [] userGecos #else myUserGecos = error "myUserGecos TODO" #endif #endif -#if 0 +#ifndef mingw32_HOST_OS myVal :: [String] -> (UserEntry -> String) -> IO String myVal envvars extract = maybe (extract <$> getpwent) return =<< check envvars where |