Restructure modules
This commit is contained in:
26
System/FileSystem/FileExt.hs
Normal file
26
System/FileSystem/FileExt.hs
Normal file
@@ -0,0 +1,26 @@
|
||||
{-# OPTIONS_HADDOCK ignore-exports #-}
|
||||
|
||||
module System.FileSystem.FileExt where
|
||||
|
||||
import MyPrelude
|
||||
|
||||
|
||||
-- |Compare the extension of a file with the given String.
|
||||
cmpExt :: String -> FilePath -> Bool
|
||||
cmpExt checkExt = (==) checkExt . getExt
|
||||
|
||||
|
||||
-- |Get the extension of a file.
|
||||
getExt :: FilePath -> String
|
||||
getExt fp
|
||||
| hasExt fp = last .
|
||||
splitBy (== '.') .
|
||||
last .
|
||||
splitBy (== '/') $
|
||||
fp
|
||||
| otherwise = ""
|
||||
|
||||
|
||||
-- |Check if the file has an extension.
|
||||
hasExt :: FilePath -> Bool
|
||||
hasExt = (>1) . length . splitBy (== '.')
|
||||
Reference in New Issue
Block a user