clean up from windows porting
This commit is contained in:
parent
d6bf05a66d
commit
18bdff3fae
28 changed files with 57 additions and 72 deletions
|
@ -24,11 +24,6 @@ module Annex.Branch (
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import qualified Data.ByteString.Lazy.Char8 as L
|
import qualified Data.ByteString.Lazy.Char8 as L
|
||||||
#ifdef __ANDROID__
|
|
||||||
import System.Posix.Env (getEnv)
|
|
||||||
#else
|
|
||||||
import System.Environment (getEnvironment)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
import Common.Annex
|
import Common.Annex
|
||||||
import Annex.BranchState
|
import Annex.BranchState
|
||||||
|
@ -45,6 +40,7 @@ import Git.FilePath
|
||||||
import Annex.CatFile
|
import Annex.CatFile
|
||||||
import Annex.Perms
|
import Annex.Perms
|
||||||
import qualified Annex
|
import qualified Annex
|
||||||
|
import Utility.Env
|
||||||
|
|
||||||
{- Name of the branch that is used to store git-annex's information. -}
|
{- Name of the branch that is used to store git-annex's information. -}
|
||||||
name :: Git.Ref
|
name :: Git.Ref
|
||||||
|
|
|
@ -33,8 +33,6 @@ import Utility.TempFile
|
||||||
import Logs.Location
|
import Logs.Location
|
||||||
import Utility.InodeCache
|
import Utility.InodeCache
|
||||||
|
|
||||||
import System.PosixCompat.Files
|
|
||||||
|
|
||||||
{- Absolute FilePaths of Files in the tree that are associated with a key. -}
|
{- Absolute FilePaths of Files in the tree that are associated with a key. -}
|
||||||
associatedFiles :: Key -> Annex [FilePath]
|
associatedFiles :: Key -> Annex [FilePath]
|
||||||
associatedFiles key = do
|
associatedFiles key = do
|
||||||
|
|
|
@ -27,8 +27,6 @@ import Utility.InodeCache
|
||||||
import Utility.CopyFile
|
import Utility.CopyFile
|
||||||
import Annex.Perms
|
import Annex.Perms
|
||||||
|
|
||||||
import System.PosixCompat.Files
|
|
||||||
|
|
||||||
{- Uses git ls-files to find files that need to be committed, and stages
|
{- Uses git ls-files to find files that need to be committed, and stages
|
||||||
- them into the index. Returns True if some changes were staged. -}
|
- them into the index. Returns True if some changes were staged. -}
|
||||||
stageDirect :: Annex Bool
|
stageDirect :: Annex Bool
|
||||||
|
|
|
@ -10,16 +10,10 @@
|
||||||
module Annex.Environment where
|
module Annex.Environment where
|
||||||
|
|
||||||
import Common.Annex
|
import Common.Annex
|
||||||
#ifndef __WINDOWS__
|
import Utility.Env
|
||||||
import Utility.UserInfo
|
import Utility.UserInfo
|
||||||
#endif
|
|
||||||
import qualified Git.Config
|
import qualified Git.Config
|
||||||
|
|
||||||
#ifndef __WINDOWS__
|
|
||||||
import System.Posix.Env
|
|
||||||
#endif
|
|
||||||
import Network.BSD
|
|
||||||
|
|
||||||
{- Checks that the system's environment allows git to function.
|
{- Checks that the system's environment allows git to function.
|
||||||
- Git requires a GECOS username, or suitable git configuration, or
|
- Git requires a GECOS username, or suitable git configuration, or
|
||||||
- environment variables. -}
|
- environment variables. -}
|
||||||
|
@ -41,7 +35,7 @@ checkEnvironmentIO =
|
||||||
where
|
where
|
||||||
#ifndef __ANDROID__
|
#ifndef __ANDROID__
|
||||||
-- existing environment is not overwritten
|
-- existing environment is not overwritten
|
||||||
ensureEnv var val = setEnv var val False
|
ensureEnv var val = void $ setEnv var val False
|
||||||
#else
|
#else
|
||||||
-- Environment setting is broken on Android, so this is dealt with
|
-- Environment setting is broken on Android, so this is dealt with
|
||||||
-- in runshell instead.
|
-- in runshell instead.
|
||||||
|
|
|
@ -19,8 +19,6 @@ import qualified Git.UpdateIndex
|
||||||
import qualified Annex.Queue
|
import qualified Annex.Queue
|
||||||
import Git.Types
|
import Git.Types
|
||||||
|
|
||||||
import System.PosixCompat.Files
|
|
||||||
|
|
||||||
type LinkTarget = String
|
type LinkTarget = String
|
||||||
|
|
||||||
{- Checks if a file is a link to a key. -}
|
{- Checks if a file is a link to a key. -}
|
||||||
|
|
|
@ -22,7 +22,6 @@ import qualified Annex
|
||||||
import Config
|
import Config
|
||||||
|
|
||||||
import System.Posix.Types
|
import System.Posix.Types
|
||||||
import System.PosixCompat.Files
|
|
||||||
|
|
||||||
withShared :: (SharedRepository -> Annex a) -> Annex a
|
withShared :: (SharedRepository -> Annex a) -> Annex a
|
||||||
withShared a = maybe startup a =<< Annex.getState Annex.shared
|
withShared a = maybe startup a =<< Annex.getState Annex.shared
|
||||||
|
|
|
@ -14,9 +14,6 @@ module Annex.Ssh (
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import qualified Data.Map as M
|
import qualified Data.Map as M
|
||||||
#ifndef __WINDOWS__
|
|
||||||
import System.Posix.Env
|
|
||||||
#endif
|
|
||||||
|
|
||||||
import Common.Annex
|
import Common.Annex
|
||||||
import Annex.LockPool
|
import Annex.LockPool
|
||||||
|
@ -24,6 +21,7 @@ import Annex.Perms
|
||||||
import qualified Build.SysConfig as SysConfig
|
import qualified Build.SysConfig as SysConfig
|
||||||
import qualified Annex
|
import qualified Annex
|
||||||
import Config
|
import Config
|
||||||
|
import Utility.Env
|
||||||
|
|
||||||
{- Generates parameters to ssh to a given host (or user@host) on a given
|
{- Generates parameters to ssh to a given host (or user@host) on a given
|
||||||
- port, with connection caching. -}
|
- port, with connection caching. -}
|
||||||
|
@ -78,11 +76,7 @@ sshCacheDir
|
||||||
)
|
)
|
||||||
| otherwise = return Nothing
|
| otherwise = return Nothing
|
||||||
where
|
where
|
||||||
#ifndef __WINDOWS__
|
|
||||||
gettmpdir = liftIO $ getEnv "GIT_ANNEX_TMP_DIR"
|
gettmpdir = liftIO $ getEnv "GIT_ANNEX_TMP_DIR"
|
||||||
#else
|
|
||||||
gettmpdir = return Nothing
|
|
||||||
#endif
|
|
||||||
usetmpdir tmpdir = liftIO $ catchMaybeIO $ do
|
usetmpdir tmpdir = liftIO $ catchMaybeIO $ do
|
||||||
createDirectoryIfMissing True tmpdir
|
createDirectoryIfMissing True tmpdir
|
||||||
return tmpdir
|
return tmpdir
|
||||||
|
|
|
@ -17,6 +17,7 @@ import Config.Files
|
||||||
import Utility.FileMode
|
import Utility.FileMode
|
||||||
import Utility.Shell
|
import Utility.Shell
|
||||||
import Utility.TempFile
|
import Utility.TempFile
|
||||||
|
import Utility.Env
|
||||||
|
|
||||||
#ifdef darwin_HOST_OS
|
#ifdef darwin_HOST_OS
|
||||||
import Utility.OSX
|
import Utility.OSX
|
||||||
|
@ -24,8 +25,6 @@ import Utility.OSX
|
||||||
import Utility.FreeDesktop
|
import Utility.FreeDesktop
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
import System.Posix.Env
|
|
||||||
|
|
||||||
standaloneAppBase :: IO (Maybe FilePath)
|
standaloneAppBase :: IO (Maybe FilePath)
|
||||||
standaloneAppBase = getEnv "GIT_ANNEX_APP_BASE"
|
standaloneAppBase = getEnv "GIT_ANNEX_APP_BASE"
|
||||||
|
|
||||||
|
|
|
@ -32,10 +32,10 @@ import qualified Remote as Remote
|
||||||
import Remote.List
|
import Remote.List
|
||||||
import Utility.FileMode
|
import Utility.FileMode
|
||||||
import Utility.Shell
|
import Utility.Shell
|
||||||
|
import Utility.Env
|
||||||
|
|
||||||
import Network.Protocol.XMPP
|
import Network.Protocol.XMPP
|
||||||
import qualified Data.Text as T
|
import qualified Data.Text as T
|
||||||
import System.Posix.Env
|
|
||||||
import System.Posix.Types
|
import System.Posix.Types
|
||||||
import System.Process (std_in, std_out, std_err)
|
import System.Process (std_in, std_out, std_err)
|
||||||
import Control.Concurrent
|
import Control.Concurrent
|
||||||
|
|
|
@ -18,7 +18,6 @@ import qualified Build.SysConfig as SysConfig
|
||||||
import Data.Digest.Pure.SHA
|
import Data.Digest.Pure.SHA
|
||||||
import qualified Data.ByteString.Lazy as L
|
import qualified Data.ByteString.Lazy as L
|
||||||
import Data.Char
|
import Data.Char
|
||||||
import System.PosixCompat.Files
|
|
||||||
|
|
||||||
type SHASize = Int
|
type SHASize = Int
|
||||||
|
|
||||||
|
|
|
@ -12,8 +12,6 @@ import Types.Backend
|
||||||
import Types.Key
|
import Types.Key
|
||||||
import Types.KeySource
|
import Types.KeySource
|
||||||
|
|
||||||
import System.PosixCompat.Files
|
|
||||||
|
|
||||||
backends :: [Backend]
|
backends :: [Backend]
|
||||||
backends = [backend]
|
backends = [backend]
|
||||||
|
|
||||||
|
|
|
@ -9,8 +9,6 @@
|
||||||
|
|
||||||
module Command.TransferKeys where
|
module Command.TransferKeys where
|
||||||
|
|
||||||
import System.PosixCompat.Files
|
|
||||||
|
|
||||||
import Common.Annex
|
import Common.Annex
|
||||||
import Command
|
import Command
|
||||||
import Annex.Content
|
import Annex.Content
|
||||||
|
|
|
@ -158,7 +158,11 @@ firstRun listenhost = do
|
||||||
sendurlback v _origout _origerr url _htmlshim = putMVar v url
|
sendurlback v _origout _origerr url _htmlshim = putMVar v url
|
||||||
|
|
||||||
openBrowser :: Maybe FilePath -> FilePath -> String -> Maybe Handle -> Maybe Handle -> IO ()
|
openBrowser :: Maybe FilePath -> FilePath -> String -> Maybe Handle -> Maybe Handle -> IO ()
|
||||||
|
#ifdef __ANDROID__
|
||||||
openBrowser mcmd htmlshim realurl outh errh = do
|
openBrowser mcmd htmlshim realurl outh errh = do
|
||||||
|
#else
|
||||||
|
openBrowser mcmd htmlshim _realurl outh errh = do
|
||||||
|
#endif
|
||||||
hPutStrLn (fromMaybe stdout outh) $ "Launching web browser on " ++ url
|
hPutStrLn (fromMaybe stdout outh) $ "Launching web browser on " ++ url
|
||||||
hFlush stdout
|
hFlush stdout
|
||||||
environ <- cleanEnvironment
|
environ <- cleanEnvironment
|
||||||
|
|
|
@ -16,8 +16,8 @@ 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)
|
||||||
|
import System.PosixCompat.Files as X
|
||||||
#ifndef mingw32_HOST_OS
|
#ifndef mingw32_HOST_OS
|
||||||
import System.Posix.Files as X
|
|
||||||
import System.Posix.IO as X
|
import System.Posix.IO as X
|
||||||
#endif
|
#endif
|
||||||
import System.Exit as X
|
import System.Exit as X
|
||||||
|
|
6
Creds.hs
6
Creds.hs
|
@ -15,11 +15,9 @@ import Utility.FileMode
|
||||||
import Crypto
|
import Crypto
|
||||||
import Types.Remote (RemoteConfig, RemoteConfigKey)
|
import Types.Remote (RemoteConfig, RemoteConfigKey)
|
||||||
import Remote.Helper.Encryptable (remoteCipher, embedCreds)
|
import Remote.Helper.Encryptable (remoteCipher, embedCreds)
|
||||||
|
import Utility.Env (setEnv)
|
||||||
|
|
||||||
import System.Environment
|
import System.Environment
|
||||||
#ifndef mingw32_HOST_OS
|
|
||||||
import System.Posix.Env (setEnv)
|
|
||||||
#endif
|
|
||||||
import qualified Data.ByteString.Lazy.Char8 as L
|
import qualified Data.ByteString.Lazy.Char8 as L
|
||||||
import qualified Data.Map as M
|
import qualified Data.Map as M
|
||||||
import Utility.Base64
|
import Utility.Base64
|
||||||
|
@ -115,7 +113,7 @@ setEnvCredPair (l, p) storage = do
|
||||||
set penv p
|
set penv p
|
||||||
where
|
where
|
||||||
(uenv, penv) = credPairEnvironment storage
|
(uenv, penv) = credPairEnvironment storage
|
||||||
set var val = setEnv var val True
|
set var val = void $ setEnv var val True
|
||||||
#else
|
#else
|
||||||
setEnvCredPair _ _ = error "setEnvCredPair TODO"
|
setEnvCredPair _ _ = error "setEnvCredPair TODO"
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -11,13 +11,13 @@ module Git.CurrentRepo where
|
||||||
|
|
||||||
#ifndef __WINDOWS__
|
#ifndef __WINDOWS__
|
||||||
import System.Posix.Directory (changeWorkingDirectory)
|
import System.Posix.Directory (changeWorkingDirectory)
|
||||||
import System.Posix.Env (getEnv, unsetEnv)
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
import Common
|
import Common
|
||||||
import Git.Types
|
import Git.Types
|
||||||
import Git.Construct
|
import Git.Construct
|
||||||
import qualified Git.Config
|
import qualified Git.Config
|
||||||
|
import Utility.Env
|
||||||
|
|
||||||
{- Gets the current git repository.
|
{- Gets the current git repository.
|
||||||
-
|
-
|
||||||
|
@ -51,7 +51,7 @@ get = do
|
||||||
v <- getEnv s
|
v <- getEnv s
|
||||||
case v of
|
case v of
|
||||||
Just d -> do
|
Just d -> do
|
||||||
unsetEnv s
|
void $ unsetEnv s
|
||||||
Just <$> absPath d
|
Just <$> absPath d
|
||||||
Nothing -> return Nothing
|
Nothing -> return Nothing
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
module Git.Index where
|
module Git.Index where
|
||||||
|
|
||||||
import System.Posix.Env (setEnv, unsetEnv, getEnv)
|
import Utility.Env
|
||||||
|
|
||||||
{- Forces git to use the specified index file.
|
{- Forces git to use the specified index file.
|
||||||
-
|
-
|
||||||
|
|
|
@ -20,7 +20,6 @@ import Utility.Percentage
|
||||||
import Utility.QuickCheck
|
import Utility.QuickCheck
|
||||||
|
|
||||||
import System.Posix.Types
|
import System.Posix.Types
|
||||||
import System.PosixCompat.Files
|
|
||||||
import Data.Time.Clock
|
import Data.Time.Clock
|
||||||
import Data.Time.Clock.POSIX
|
import Data.Time.Clock.POSIX
|
||||||
import Data.Time
|
import Data.Time
|
||||||
|
|
20
Test.hs
20
Test.hs
|
@ -13,7 +13,6 @@ import Test.QuickCheck.Test
|
||||||
|
|
||||||
import System.Posix.Directory (changeWorkingDirectory)
|
import System.Posix.Directory (changeWorkingDirectory)
|
||||||
import System.Posix.Files
|
import System.Posix.Files
|
||||||
import System.Posix.Env
|
|
||||||
import Control.Exception.Extensible
|
import Control.Exception.Extensible
|
||||||
import qualified Data.Map as M
|
import qualified Data.Map as M
|
||||||
import System.IO.HVFS (SystemFS(..))
|
import System.IO.HVFS (SystemFS(..))
|
||||||
|
@ -53,6 +52,7 @@ import qualified Utility.Verifiable
|
||||||
import qualified Utility.Process
|
import qualified Utility.Process
|
||||||
import qualified Utility.Misc
|
import qualified Utility.Misc
|
||||||
import qualified Utility.InodeCache
|
import qualified Utility.InodeCache
|
||||||
|
import qualified Utility.Env
|
||||||
|
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
main = do
|
main = do
|
||||||
|
@ -726,7 +726,7 @@ test_bup_remote = "git-annex bup remote" ~: intmpclonerepo $ when Build.SysConfi
|
||||||
test_crypto :: Test
|
test_crypto :: Test
|
||||||
test_crypto = "git-annex crypto" ~: intmpclonerepo $ when Build.SysConfig.gpg $ do
|
test_crypto = "git-annex crypto" ~: intmpclonerepo $ when Build.SysConfig.gpg $ do
|
||||||
-- force gpg into batch mode for the tests
|
-- force gpg into batch mode for the tests
|
||||||
setEnv "GPG_BATCH" "1" True
|
void $ Utility.Env.setEnv "GPG_BATCH" "1" True
|
||||||
Utility.Gpg.testTestHarness @? "test harness self-test failed"
|
Utility.Gpg.testTestHarness @? "test harness self-test failed"
|
||||||
Utility.Gpg.testHarness $ do
|
Utility.Gpg.testHarness $ do
|
||||||
createDirectory "dir"
|
createDirectory "dir"
|
||||||
|
@ -947,20 +947,20 @@ prepare = do
|
||||||
-- and so does git_annex_output. Make sure that the just-built
|
-- and so does git_annex_output. Make sure that the just-built
|
||||||
-- git annex is used.
|
-- git annex is used.
|
||||||
cwd <- getCurrentDirectory
|
cwd <- getCurrentDirectory
|
||||||
p <- getEnvDefault "PATH" ""
|
p <- Utility.Env.getEnvDefault "PATH" ""
|
||||||
setEnv "PATH" (cwd ++ ":" ++ p) True
|
void $ Utility.Env.setEnv "PATH" (cwd ++ ":" ++ p) True
|
||||||
setEnv "TOPDIR" cwd True
|
void $Utility.Env.setEnv "TOPDIR" cwd True
|
||||||
-- Avoid git complaining if it cannot determine the user's email
|
-- Avoid git complaining if it cannot determine the user's email
|
||||||
-- address, or exploding if it doesn't know the user's name.
|
-- address, or exploding if it doesn't know the user's name.
|
||||||
setEnv "GIT_AUTHOR_EMAIL" "test@example.com" True
|
void $ Utility.Env.setEnv "GIT_AUTHOR_EMAIL" "test@example.com" True
|
||||||
setEnv "GIT_AUTHOR_NAME" "git-annex test" True
|
void $ Utility.Env.setEnv "GIT_AUTHOR_NAME" "git-annex test" True
|
||||||
setEnv "GIT_COMMITTER_EMAIL" "test@example.com" True
|
void $ Utility.Env.setEnv "GIT_COMMITTER_EMAIL" "test@example.com" True
|
||||||
setEnv "GIT_COMMITTER_NAME" "git-annex test" True
|
void $ Utility.Env.setEnv "GIT_COMMITTER_NAME" "git-annex test" True
|
||||||
|
|
||||||
changeToTmpDir :: FilePath -> IO ()
|
changeToTmpDir :: FilePath -> IO ()
|
||||||
changeToTmpDir t = do
|
changeToTmpDir t = do
|
||||||
-- Hack alert. Threading state to here was too much bother.
|
-- Hack alert. Threading state to here was too much bother.
|
||||||
topdir <- getEnvDefault "TOPDIR" ""
|
topdir <- Utility.Env.getEnvDefault "TOPDIR" ""
|
||||||
changeWorkingDirectory $ topdir ++ "/" ++ t
|
changeWorkingDirectory $ topdir ++ "/" ++ t
|
||||||
|
|
||||||
tmpdir :: String
|
tmpdir :: String
|
||||||
|
|
|
@ -14,8 +14,9 @@ import Utility.LogFile
|
||||||
|
|
||||||
#ifndef __WINDOWS__
|
#ifndef __WINDOWS__
|
||||||
import System.Posix
|
import System.Posix
|
||||||
#endif
|
#else
|
||||||
import System.Posix.Types
|
import System.Posix.Types
|
||||||
|
#endif
|
||||||
|
|
||||||
{- Run an action as a daemon, with all output sent to a file descriptor.
|
{- Run an action as a daemon, with all output sent to a file descriptor.
|
||||||
-
|
-
|
||||||
|
|
|
@ -10,28 +10,35 @@
|
||||||
module Utility.Env where
|
module Utility.Env where
|
||||||
|
|
||||||
#ifdef __WINDOWS__
|
#ifdef __WINDOWS__
|
||||||
import qualified System.Environment as E
|
|
||||||
import Utility.Exception
|
import Utility.Exception
|
||||||
|
import qualified System.Environment as E
|
||||||
#else
|
#else
|
||||||
import qualified System.Posix.Env as E
|
import qualified System.Posix.Env as PE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
{- Posix getEnv is faster than the one in System.Environment,
|
{- Posix getEnv is faster than the one in System.Environment,
|
||||||
- so use when available. -}
|
- so use when available. -}
|
||||||
getEnv :: String -> IO (Maybe String)
|
getEnv :: String -> IO (Maybe String)
|
||||||
#ifndef __WINDOWS__
|
#ifndef __WINDOWS__
|
||||||
getEnv = E.getEnv
|
getEnv = PE.getEnv
|
||||||
#else
|
#else
|
||||||
getEnv = catchMaybeIO . E.getEnv
|
getEnv = catchMaybeIO . E.getEnv
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
getEnvDefault :: String -> String -> IO String
|
getEnvDefault :: String -> String -> IO String
|
||||||
#ifndef __WINDOWS__
|
#ifndef __WINDOWS__
|
||||||
getEnvDefault = E.getEnvDefault
|
getEnvDefault = PE.getEnvDefault
|
||||||
#else
|
#else
|
||||||
getEnvDefault var fallback = fromMaybe fallback <$> getEnv var
|
getEnvDefault var fallback = fromMaybe fallback <$> getEnv var
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
getEnvironment :: IO [(String, String)]
|
||||||
|
#ifndef __WINDOWS__
|
||||||
|
getEnvironment = PE.getEnvironment
|
||||||
|
#else
|
||||||
|
getEnvironment = E.getEnvironment
|
||||||
|
#endif
|
||||||
|
|
||||||
{- Returns True if it could successfully set the environment variable.
|
{- Returns True if it could successfully set the environment variable.
|
||||||
-
|
-
|
||||||
- There is, apparently, no way to do this in Windows. Instead,
|
- There is, apparently, no way to do this in Windows. Instead,
|
||||||
|
@ -39,8 +46,18 @@ getEnvDefault var fallback = fromMaybe fallback <$> getEnv var
|
||||||
setEnv :: String -> String -> Bool -> IO Bool
|
setEnv :: String -> String -> Bool -> IO Bool
|
||||||
#ifndef __WINDOWS__
|
#ifndef __WINDOWS__
|
||||||
setEnv var val overwrite = do
|
setEnv var val overwrite = do
|
||||||
E.setEnv var val overwrite
|
PE.setEnv var val overwrite
|
||||||
return True
|
return True
|
||||||
#else
|
#else
|
||||||
setEnv _ _ _ = return False
|
setEnv _ _ _ = return False
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
{- Returns True if it could successfully unset the environment variable. -}
|
||||||
|
unsetEnv :: String -> IO Bool
|
||||||
|
#ifndef __WINDOWS__
|
||||||
|
unsetEnv var = do
|
||||||
|
PE.unsetEnv var
|
||||||
|
return True
|
||||||
|
#else
|
||||||
|
unsetEnv _ _ _ = return False
|
||||||
|
#endif
|
||||||
|
|
|
@ -12,9 +12,10 @@ module Utility.FileMode where
|
||||||
import Common
|
import Common
|
||||||
|
|
||||||
import Control.Exception (bracket)
|
import Control.Exception (bracket)
|
||||||
import Utility.Exception
|
|
||||||
import System.PosixCompat.Types
|
import System.PosixCompat.Types
|
||||||
import System.PosixCompat.Files
|
#ifndef __WINDOWS__
|
||||||
|
import System.Posix.Files
|
||||||
|
#endif
|
||||||
import Foreign (complement)
|
import Foreign (complement)
|
||||||
|
|
||||||
{- Applies a conversion function to a file's mode. -}
|
{- Applies a conversion function to a file's mode. -}
|
||||||
|
|
|
@ -13,11 +13,9 @@ import System.Posix.Types
|
||||||
import Control.Applicative
|
import Control.Applicative
|
||||||
import Control.Concurrent
|
import Control.Concurrent
|
||||||
import Control.Exception (bracket)
|
import Control.Exception (bracket)
|
||||||
#ifndef mingw32_HOST_OS
|
|
||||||
import System.Posix.Env (setEnv, unsetEnv, getEnv)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
import Common
|
import Common
|
||||||
|
import Utility.Env
|
||||||
|
|
||||||
newtype KeyIds = KeyIds [String]
|
newtype KeyIds = KeyIds [String]
|
||||||
deriving (Ord, Eq)
|
deriving (Ord, Eq)
|
||||||
|
@ -229,7 +227,7 @@ testHarness a = do
|
||||||
setup = do
|
setup = do
|
||||||
base <- getTemporaryDirectory
|
base <- getTemporaryDirectory
|
||||||
dir <- mktmpdir $ base </> "gpgtmpXXXXXX"
|
dir <- mktmpdir $ base </> "gpgtmpXXXXXX"
|
||||||
setEnv var dir True
|
void $ setEnv var dir True
|
||||||
_ <- pipeStrict [Params "--import -q"] $ unlines
|
_ <- pipeStrict [Params "--import -q"] $ unlines
|
||||||
[testSecretKey, testKey]
|
[testSecretKey, testKey]
|
||||||
return dir
|
return dir
|
||||||
|
|
|
@ -9,7 +9,6 @@ module Utility.InodeCache where
|
||||||
|
|
||||||
import Common
|
import Common
|
||||||
import System.PosixCompat.Types
|
import System.PosixCompat.Types
|
||||||
import System.PosixCompat.Files
|
|
||||||
import Utility.QuickCheck
|
import Utility.QuickCheck
|
||||||
|
|
||||||
data InodeCachePrim = InodeCachePrim FileID FileOffset EpochTime
|
data InodeCachePrim = InodeCachePrim FileID FileOffset EpochTime
|
||||||
|
|
|
@ -12,7 +12,6 @@ module Utility.LogFile where
|
||||||
import Common
|
import Common
|
||||||
|
|
||||||
import System.Posix.Types
|
import System.Posix.Types
|
||||||
import System.PosixCompat.Files
|
|
||||||
|
|
||||||
openLog :: FilePath -> IO Fd
|
openLog :: FilePath -> IO Fd
|
||||||
#ifndef __WINDOWS__
|
#ifndef __WINDOWS__
|
||||||
|
|
|
@ -11,9 +11,9 @@ module Utility.Lsof where
|
||||||
|
|
||||||
import Common
|
import Common
|
||||||
import Build.SysConfig as SysConfig
|
import Build.SysConfig as SysConfig
|
||||||
|
import Utility.Env
|
||||||
|
|
||||||
import System.Posix.Types
|
import System.Posix.Types
|
||||||
import System.Posix.Env
|
|
||||||
|
|
||||||
data LsofOpenMode = OpenReadWrite | OpenReadOnly | OpenWriteOnly | OpenUnknown
|
data LsofOpenMode = OpenReadWrite | OpenReadOnly | OpenWriteOnly | OpenUnknown
|
||||||
deriving (Show, Eq)
|
deriving (Show, Eq)
|
||||||
|
@ -32,7 +32,7 @@ setupLsof = do
|
||||||
when (isAbsolute cmd) $ do
|
when (isAbsolute cmd) $ do
|
||||||
path <- getSearchPath
|
path <- getSearchPath
|
||||||
let path' = takeDirectory cmd : path
|
let path' = takeDirectory cmd : path
|
||||||
setEnv "PATH" (intercalate [searchPathSeparator] path') True
|
void $ setEnv "PATH" (intercalate [searchPathSeparator] path') True
|
||||||
|
|
||||||
{- Checks each of the files in a directory to find open files.
|
{- Checks each of the files in a directory to find open files.
|
||||||
- Note that this will find hard links to files elsewhere that are open. -}
|
- Note that this will find hard links to files elsewhere that are open. -}
|
||||||
|
|
|
@ -20,7 +20,6 @@ import Network.URI
|
||||||
import qualified Network.Browser as Browser
|
import qualified Network.Browser as Browser
|
||||||
import Network.HTTP
|
import Network.HTTP
|
||||||
import Data.Either
|
import Data.Either
|
||||||
import System.PosixCompat.Files
|
|
||||||
|
|
||||||
import qualified Build.SysConfig
|
import qualified Build.SysConfig
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,6 @@ module Utility.UserInfo (
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Control.Applicative
|
import Control.Applicative
|
||||||
import System.Posix.Types
|
|
||||||
import System.PosixCompat
|
import System.PosixCompat
|
||||||
|
|
||||||
import Utility.Env
|
import Utility.Env
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue