filemanip 0.3.6.2 → 0.3.6.3
raw patch · 3 files changed
+28/−10 lines, 3 filesdep ~basedep ~bytestringdep ~directoryPVP: minor bump suggested
API additions: PVP suggests at least a minor version bump
Dependency ranges changed: base, bytestring, directory, filepath, mtl, unix-compat
API changes (from Hackage documentation)
+ System.FilePath.Find: canonicalName :: FindClause FilePath
+ System.FilePath.Find: canonicalPath :: FindClause FilePath
+ System.FilePath.Find: instance Applicative FindClause
Files
- System/FilePath/Find.hs +26/−8
- System/FilePath/GlobPattern.hs +1/−1
- filemanip.cabal +1/−1
System/FilePath/Find.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE GeneralizedNewtypeDeriving, ScopedTypeVariables #-}+{-# LANGUAGE CPP, GeneralizedNewtypeDeriving, ScopedTypeVariables #-} {-# OPTIONS_GHC -fno-warn-orphans #-} -- |@@ -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 @@ , filePerms , anyPerms + -- ** Combinators for canonical path and name+ , canonicalPath+ , canonicalName+ -- ** Combinators that operate on symbolic links , readLink , followStatus@@ -111,13 +115,16 @@ , (||?) ) where +#if !MIN_VERSION_base(4,8,0)+import Control.Applicative (Applicative)+#endif import qualified Control.Exception as E import Control.Exception (IOException, handle) 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)@@ -147,7 +154,7 @@ -- construction of combinators. Wraps the 'State' monad, but doesn't -- allow 'get' or 'put'. newtype FindClause a = FC { runFC :: State FileInfo a }- deriving (Functor, Monad)+ deriving (Functor, Applicative, Monad) -- | Run the given 'FindClause' on the given 'FileInfo' and return its -- result. This can be useful if you are writing a function to pass@@ -291,7 +298,7 @@ -> IO a fold = foldWithHandler warnOnError- where warnOnError path a err = + where warnOnError path a err = hPutStrLn stderr (path ++ ": " ++ show err) >> return a -- | Unconditionally return 'True'.@@ -341,6 +348,17 @@ 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.@@ -408,7 +426,7 @@ statusType _ = Unknown -- $statusFunctions--- +-- -- These are simply lifted versions of the 'F.FileStatus' accessor -- functions in the "System.Posix.Files" module. The definitions all -- have the following form:@@ -486,12 +504,12 @@ liftOp f a b = a >>= \a' -> return (f a' b) -- $binaryOperators--- +-- -- These are lifted versions of the most commonly used binary -- operators. They have the same fixities and associativities as -- their unlifted counterparts. They are lifted using 'liftOp', like -- so:--- +-- -- @('==?') = 'liftOp' (==)@ -- | Return 'True' if the current file's name matches the given
System/FilePath/GlobPattern.hs view
@@ -152,7 +152,7 @@ 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
filemanip.cabal view
@@ -1,5 +1,5 @@ Name: filemanip-Version: 0.3.6.2+Version: 0.3.6.3 License: BSD3 License-File: LICENSE Author: Bryan O'Sullivan <bos@serpentine.com>