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