Add utility functions for file handling
This commit is contained in:
parent
aec00c7e4d
commit
d0f524167a
17
Util.hs
17
Util.hs
@ -11,3 +11,20 @@ inRange min' max' (x, y)
|
|||||||
| otherwise = False
|
| otherwise = False
|
||||||
|
|
||||||
|
|
||||||
|
cmpExt :: String -> FilePath -> Bool
|
||||||
|
cmpExt _ [] = False
|
||||||
|
cmpExt ext fp = ext == getExt fp
|
||||||
|
|
||||||
|
|
||||||
|
getExt :: FilePath -> String
|
||||||
|
getExt = last .
|
||||||
|
splitBy (== '.') .
|
||||||
|
last .
|
||||||
|
splitBy (== '/')
|
||||||
|
|
||||||
|
|
||||||
|
splitBy :: (a -> Bool) -> [a] -> [[a]]
|
||||||
|
splitBy f s = case dropWhile f s of
|
||||||
|
[] -> []
|
||||||
|
s' -> w : splitBy f s''
|
||||||
|
where (w, s'') = break f s'
|
||||||
|
Loading…
Reference in New Issue
Block a user