summaryrefslogtreecommitdiff
path: root/Limit.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-02-11 16:00:58 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-02-11 16:00:58 -0400
commit66864d5d99e595e56ed77bd89312abc43d593c83 (patch)
tree47bb74bc92145c51faf76632785500e1bad3a30e /Limit.hs
parent4b5aa38d39f4bef06bcbface980584d2654bcd28 (diff)
parente658dc378eaa14607278cddd30f965ffcff89426 (diff)
Merge branch 'android'
Diffstat (limited to 'Limit.hs')
-rw-r--r--Limit.hs16
1 files changed, 14 insertions, 2 deletions
diff --git a/Limit.hs b/Limit.hs
index 80608bcc6..16e555bed 100644
--- a/Limit.hs
+++ b/Limit.hs
@@ -5,13 +5,19 @@
- Licensed under the GNU GPL version 3 or higher.
-}
+{-# LANGUAGE CPP #-}
+
module Limit where
-import Text.Regex.PCRE.Light.Char8
-import System.Path.WildMatch
import Data.Time.Clock.POSIX
import qualified Data.Set as S
import qualified Data.Map as M
+#ifdef WITH_GLOB
+import System.FilePath.Glob (simplify, compile, match)
+#else
+import Text.Regex.PCRE.Light.Char8
+import System.Path.WildMatch
+#endif
import Common.Annex
import qualified Annex
@@ -82,10 +88,16 @@ limitExclude glob = Right $ const $ return . not . matchglob glob
matchglob :: String -> Annex.FileInfo -> Bool
matchglob glob (Annex.FileInfo { Annex.matchFile = f }) =
+#ifdef WITH_GLOB
+ match pattern f
+ where
+ pattern = simplify $ compile glob
+#else
isJust $ match cregex f []
where
cregex = compile regex []
regex = '^':wildToRegex glob
+#endif
{- Adds a limit to skip files not believed to be present
- in a specfied repository. -}