2 {-# OPTIONS_GHC -fno-warn-unused-imports #-}
4 module Distribution
.Compat
.FilePath
9 import Data
.List
(isSuffixOf, stripPrefix
)
10 import System
.FilePath
12 #if !MIN_VERSION_filepath
(1,4,2)
13 isExtensionOf
:: String -> FilePath -> Bool
14 isExtensionOf ext
@('.':_
) = isSuffixOf ext
. takeExtensions
15 isExtensionOf ext
= isSuffixOf ('.':ext
) . takeExtensions
18 #if !MIN_VERSION_filepath
(1,4,1)
19 stripExtension
:: String -> FilePath -> Maybe FilePath
20 stripExtension
[] path
= Just path
21 stripExtension ext
@(x
:_
) path
= stripSuffix dotExt path
23 dotExt
= if isExtSeparator x
then ext
else '.':ext
24 stripSuffix
:: Eq a
=> [a
] -> [a
] -> Maybe [a
]
25 stripSuffix xs ys
= fmap reverse $ stripPrefix
(reverse xs
) (reverse ys
)