Fix for bytestring versions less than 0.10.8
This commit is contained in:
parent
ae9a806c2e
commit
b55cf6d9f3
@ -32,7 +32,7 @@ library
|
||||
System.Posix.FD,
|
||||
System.Posix.FilePath
|
||||
build-depends: base >= 4.2 && <5
|
||||
, bytestring >= 0.10.8.0
|
||||
, bytestring >= 0.9.2.0
|
||||
, deepseq
|
||||
, exceptions
|
||||
, hspec
|
||||
|
@ -12,6 +12,7 @@
|
||||
-- Not all functions of "System.FilePath" are implemented yet. Feel free to contribute!
|
||||
|
||||
|
||||
{-# LANGUAGE CPP #-}
|
||||
{-# LANGUAGE TupleSections #-}
|
||||
|
||||
{-# OPTIONS_GHC -Wall #-}
|
||||
@ -86,7 +87,9 @@ import qualified System.Posix.Env.ByteString as PE
|
||||
|
||||
import Data.Maybe (isJust)
|
||||
import Data.Word8
|
||||
|
||||
#if !MIN_VERSION_bytestring(0,10,8)
|
||||
import qualified Data.List as L
|
||||
#endif
|
||||
import Control.Arrow (second)
|
||||
|
||||
-- $setup
|
||||
@ -319,12 +322,16 @@ takeExtensions = snd . splitExtensions
|
||||
stripExtension :: ByteString -> RawFilePath -> Maybe RawFilePath
|
||||
stripExtension bs path
|
||||
| BS.null bs = Just path
|
||||
| otherwise = BS.stripSuffix dotExt path
|
||||
| otherwise = stripSuffix' dotExt path
|
||||
where
|
||||
dotExt = if isExtSeparator $ BS.head bs
|
||||
then bs
|
||||
else extSeparator `BS.cons` bs
|
||||
|
||||
#if MIN_VERSION_bytestring(0,10,8)
|
||||
stripSuffix' = BS.stripSuffix
|
||||
#else
|
||||
stripSuffix' xs ys = fmap (BS.pack . reverse) $ stripPrefix (reverse $ BS.unpack xs) (reverse $ BS.unpack ys)
|
||||
#endif
|
||||
|
||||
|
||||
------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user