FileManip: migrated to extenible-exceptions
--HG-- extra : convert_revision : 65e5f9c80e000fc9680da857ea7a255f3125b614
This commit is contained in:
parent
1a7b99ac4e
commit
fb34509cf1
5 changed files with 53 additions and 5 deletions
|
@ -10,6 +10,8 @@ Description: A Haskell library for working with files and directories.
|
|||
Includes code for pattern matching, finding files,
|
||||
modifying file contents, and more.
|
||||
Cabal-version: >= 1.2
|
||||
Build-type: Simple
|
||||
|
||||
Extra-Source-Files: README
|
||||
|
||||
Flag splitBase
|
||||
|
@ -17,9 +19,9 @@ Flag splitBase
|
|||
|
||||
Library
|
||||
if flag(splitBase)
|
||||
Build-Depends: base, bytestring, directory, filepath, mtl, unix
|
||||
Build-Depends: base >= 2 && < 5, bytestring, directory, filepath, mtl, unix, extensible-exceptions
|
||||
else
|
||||
Build-Depends: base, filepath, mtl, unix
|
||||
Build-Depends: base >= 2 && < 5, filepath, mtl, unix, extensible-exceptions
|
||||
|
||||
GHC-Options: -Wall -O2
|
||||
Exposed-Modules:
|
||||
|
@ -27,3 +29,5 @@ Library
|
|||
System.FilePath.Glob,
|
||||
System.FilePath.GlobPattern,
|
||||
System.FilePath.Manip
|
||||
Other-Modules:
|
||||
System.FilePath.Error
|
||||
|
|
42
System/FilePath/Error.hs
Normal file
42
System/FilePath/Error.hs
Normal file
|
@ -0,0 +1,42 @@
|
|||
{-# LANGUAGE FlexibleInstances, TypeSynonymInstances #-}
|
||||
|
||||
-- |
|
||||
-- Module: System.FilePath.Manip
|
||||
-- Copyright: Sergei Trofimovich
|
||||
-- License: BSD3
|
||||
-- Maintainer: Bryan O'Sullivan <bos@serpentine.com>
|
||||
-- Stability: unstable
|
||||
-- Portability: Unix-like systems (requires flexible instances)
|
||||
|
||||
module System.FilePath.Error
|
||||
(
|
||||
bracket
|
||||
, bracket_
|
||||
, catch
|
||||
, handle
|
||||
, throwIO
|
||||
, Exception
|
||||
) where
|
||||
|
||||
import qualified Control.Exception.Extensible as EE
|
||||
import Prelude hiding (catch)
|
||||
|
||||
-- we can catch any exceptions if we need to
|
||||
-- type Exception = SomeException
|
||||
type Exception = EE.IOException
|
||||
|
||||
-- we just pin down 'EE.Exception e' to local Exception
|
||||
bracket :: IO a -> (a -> IO b) -> (a -> IO c) -> IO c
|
||||
bracket = EE.bracket
|
||||
|
||||
bracket_ :: IO a -> IO b -> IO c -> IO c
|
||||
bracket_ = EE.bracket_
|
||||
|
||||
catch :: IO a -> (Exception -> IO a) -> IO a
|
||||
catch = EE.catch
|
||||
|
||||
handle :: (Exception -> IO a) -> IO a -> IO a
|
||||
handle = EE.handle
|
||||
|
||||
throwIO :: (EE.Exception e) => e -> IO a
|
||||
throwIO = EE.throwIO
|
|
@ -119,7 +119,7 @@ import System.FilePath ((</>), takeDirectory, takeExtension, takeFileName)
|
|||
import System.FilePath.GlobPattern (GlobPattern, (~~), (/~))
|
||||
import System.IO (hPutStrLn, stderr)
|
||||
import System.IO.Unsafe (unsafeInterleaveIO, unsafePerformIO)
|
||||
import qualified Control.Exception as E
|
||||
import qualified System.FilePath.Error as E
|
||||
import qualified System.Posix.Files as F
|
||||
import qualified System.Posix.Types as T
|
||||
|
||||
|
|
|
@ -10,7 +10,6 @@ module System.FilePath.Glob (
|
|||
namesMatching
|
||||
) where
|
||||
|
||||
import Control.Exception (handle)
|
||||
import Control.Monad (forM)
|
||||
import System.FilePath.GlobPattern ((~~))
|
||||
import System.Directory (doesDirectoryExist, doesFileExist,
|
||||
|
@ -18,6 +17,8 @@ import System.Directory (doesDirectoryExist, doesFileExist,
|
|||
import System.FilePath (dropTrailingPathSeparator, splitFileName, (</>))
|
||||
import System.IO.Unsafe (unsafeInterleaveIO)
|
||||
|
||||
import System.FilePath.Error (handle)
|
||||
|
||||
-- | Return a list of names matching a glob pattern. The list is
|
||||
-- generated lazily.
|
||||
namesMatching :: String -> IO [FilePath]
|
||||
|
|
|
@ -16,7 +16,8 @@ module System.FilePath.Manip (
|
|||
, modifyInPlace
|
||||
) where
|
||||
|
||||
import Control.Exception (bracket, bracket_, handle, throwIO)
|
||||
import System.FilePath.Error (bracket, bracket_, handle, throwIO)
|
||||
|
||||
import Control.Monad (liftM)
|
||||
import Data.Bits ((.&.))
|
||||
import System.Directory (removeFile)
|
||||
|
|
Loading…
Add table
Reference in a new issue