2014-10-06 23:14:23 +02:00
|
|
|
{-# OPTIONS_HADDOCK ignore-exports #-}
|
|
|
|
|
|
2014-10-10 17:40:08 +02:00
|
|
|
module System.FileSystem.FileExt where
|
2014-10-01 00:05:29 +02:00
|
|
|
|
2014-10-10 17:40:08 +02:00
|
|
|
import MyPrelude
|
2014-10-07 19:22:37 +02:00
|
|
|
|
2014-10-01 00:05:29 +02:00
|
|
|
|
2014-10-01 23:02:43 +02:00
|
|
|
-- |Compare the extension of a file with the given String.
|
2014-10-01 20:18:45 +02:00
|
|
|
cmpExt :: String -> FilePath -> Bool
|
2014-10-06 02:26:04 +02:00
|
|
|
cmpExt checkExt = (==) checkExt . getExt
|
2014-10-01 20:18:45 +02:00
|
|
|
|
|
|
|
|
|
2014-10-01 23:02:43 +02:00
|
|
|
-- |Get the extension of a file.
|
2014-10-01 20:18:45 +02:00
|
|
|
getExt :: FilePath -> String
|
2014-10-06 02:26:04 +02:00
|
|
|
getExt fp
|
2014-10-10 00:19:05 +02:00
|
|
|
| hasExt fp = last .
|
|
|
|
|
splitBy (== '.') .
|
|
|
|
|
last .
|
|
|
|
|
splitBy (== '/') $
|
|
|
|
|
fp
|
2014-10-06 02:26:04 +02:00
|
|
|
| otherwise = ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- |Check if the file has an extension.
|
|
|
|
|
hasExt :: FilePath -> Bool
|
2014-10-07 00:41:03 +02:00
|
|
|
hasExt = (>1) . length . splitBy (== '.')
|