Add utility functions for file handling

This commit is contained in:
2014-10-01 20:18:45 +02:00
parent aec00c7e4d
commit d0f524167a

17
Util.hs
View File

@@ -11,3 +11,20 @@ inRange min' max' (x, y)
| 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'