Fakey fakey merge
This commit is contained in:
commit
b7d7bb5224
3 changed files with 19 additions and 4 deletions
|
@ -29,7 +29,7 @@
|
|||
-- Because 'FindClause' is a monad, you can use the usual monad
|
||||
-- machinery to, for example, lift pure functions into it.
|
||||
--
|
||||
-- Here's a clause that will return 'False' for any file whose
|
||||
-- Here's a clause that will return 'True' for any file whose
|
||||
-- directory name contains the word @\"temp\"@.
|
||||
--
|
||||
-- @
|
||||
|
@ -90,6 +90,10 @@ module System.FilePath.Find (
|
|||
, filePerms
|
||||
, anyPerms
|
||||
|
||||
-- ** Combinators for canonical path and name
|
||||
, canonicalPath
|
||||
, canonicalName
|
||||
|
||||
-- ** Combinators that operate on symbolic links
|
||||
, readLink
|
||||
, followStatus
|
||||
|
@ -117,7 +121,7 @@ import Control.Monad (foldM, forM, liftM, liftM2)
|
|||
import Control.Monad.State (State, evalState, get)
|
||||
import Data.Bits (Bits, (.&.))
|
||||
import Data.List (sort)
|
||||
import System.Directory (getDirectoryContents)
|
||||
import System.Directory (getDirectoryContents, canonicalizePath)
|
||||
import System.FilePath ((</>), takeDirectory, takeExtension, takeFileName)
|
||||
import System.FilePath.GlobPattern (GlobPattern, (~~), (/~))
|
||||
import System.IO (hPutStrLn, stderr)
|
||||
|
@ -341,6 +345,17 @@ fileName = takeFileName `liftM` filePath
|
|||
directory :: FindClause FilePath
|
||||
directory = takeDirectory `liftM` filePath
|
||||
|
||||
-- | Return the canonical path of the file being visited.
|
||||
--
|
||||
-- See `canonicalizePath` for details of what canonical path means.
|
||||
canonicalPath :: FindClause FilePath
|
||||
canonicalPath = (unsafePerformIO . canonicalizePath) `liftM` filePath
|
||||
|
||||
-- | Return the canonical name of the file (canonical path with the
|
||||
-- directory part removed).
|
||||
canonicalName :: FindClause FilePath
|
||||
canonicalName = takeFileName `liftM` canonicalPath
|
||||
|
||||
-- | Run the given action in the 'IO' monad (using 'unsafePerformIO')
|
||||
-- if the current file is a symlink. Hide errors by wrapping results
|
||||
-- in the 'Maybe' monad.
|
||||
|
|
|
@ -152,7 +152,7 @@ matchTerms (MatchAny:ts) cs = matchAny cs >>= matchTerms ts
|
|||
where matchAny [] = fail "no match"
|
||||
matchAny cs' = case matchTerms ts cs' of
|
||||
Nothing -> matchAny (tail cs')
|
||||
_ -> return cs
|
||||
_ -> return cs'
|
||||
matchTerms [MatchDir] cs | pathSeparator `elem` cs = fail "path separator"
|
||||
| otherwise = return ()
|
||||
matchTerms (MatchDir:ts) cs = matchDir cs >>= matchTerms ts
|
||||
|
|
|
@ -33,7 +33,7 @@ renameCppToC path = find always (extension ==? ".cpp") path >>=
|
|||
|
||||
noRCS :: RecursionPredicate
|
||||
|
||||
noRCS = (`elem` ["_darcs","SCCS","CVS",".svn",".hg",".git"]) `liftM` fileName
|
||||
noRCS = (`notElem` ["_darcs","SCCS","CVS",".svn",".hg",".git"]) `liftM` fileName
|
||||
|
||||
cSources :: FilePath -> IO [FilePath]
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue