diff options
Diffstat (limited to 'Utility')
-rw-r--r-- | Utility/Directory.hs | 9 | ||||
-rw-r--r-- | Utility/QuickCheck.hs | 7 | ||||
-rw-r--r-- | Utility/SystemDirectory.hs | 16 |
3 files changed, 26 insertions, 6 deletions
diff --git a/Utility/Directory.hs b/Utility/Directory.hs index fae33b5..693e771 100644 --- a/Utility/Directory.hs +++ b/Utility/Directory.hs @@ -8,10 +8,12 @@ {-# LANGUAGE CPP #-} {-# OPTIONS_GHC -fno-warn-tabs #-} -module Utility.Directory where +module Utility.Directory ( + module Utility.Directory, + module Utility.SystemDirectory +) where import System.IO.Error -import System.Directory import Control.Monad import System.FilePath import Control.Applicative @@ -28,6 +30,7 @@ import Utility.SafeCommand import Control.Monad.IfElse #endif +import Utility.SystemDirectory import Utility.PosixFiles import Utility.Tmp import Utility.Exception @@ -134,11 +137,13 @@ moveFile src dest = tryIO (rename src dest) >>= onrename _ <- tryIO $ removeFile tmp throwM e' +#ifndef mingw32_HOST_OS isdir f = do r <- tryIO $ getFileStatus f case r of (Left _) -> return False (Right s) -> return $ isDirectory s +#endif {- Removes a file, which may or may not exist, and does not have to - be a regular file. diff --git a/Utility/QuickCheck.hs b/Utility/QuickCheck.hs index cd408dd..2009476 100644 --- a/Utility/QuickCheck.hs +++ b/Utility/QuickCheck.hs @@ -6,7 +6,7 @@ -} {-# OPTIONS_GHC -fno-warn-orphans #-} -{-# LANGUAGE TypeSynonymInstances #-} +{-# LANGUAGE TypeSynonymInstances, CPP #-} module Utility.QuickCheck ( module X @@ -21,19 +21,18 @@ import qualified Data.Set as S import Control.Applicative import Prelude +#if ! MIN_VERSION_QuickCheck(2,8,2) instance (Arbitrary k, Arbitrary v, Eq k, Ord k) => Arbitrary (M.Map k v) where arbitrary = M.fromList <$> arbitrary instance (Arbitrary v, Eq v, Ord v) => Arbitrary (S.Set v) where arbitrary = S.fromList <$> arbitrary +#endif {- Times before the epoch are excluded. -} instance Arbitrary POSIXTime where arbitrary = fromInteger <$> nonNegative arbitrarySizedIntegral -instance Arbitrary EpochTime where - arbitrary = fromInteger <$> nonNegative arbitrarySizedIntegral - {- Pids are never negative, or 0. -} instance Arbitrary ProcessID where arbitrary = arbitrarySizedBoundedIntegral `suchThat` (> 0) diff --git a/Utility/SystemDirectory.hs b/Utility/SystemDirectory.hs new file mode 100644 index 0000000..3dd44d1 --- /dev/null +++ b/Utility/SystemDirectory.hs @@ -0,0 +1,16 @@ +{- System.Directory without its conflicting isSymbolicLink + - + - Copyright 2016 Joey Hess <id@joeyh.name> + - + - License: BSD-2-clause + -} + +-- Disable warnings because only some versions of System.Directory export +-- isSymbolicLink. +{-# OPTIONS_GHC -fno-warn-tabs -w #-} + +module Utility.SystemDirectory ( + module System.Directory +) where + +import System.Directory hiding (isSymbolicLink) |