Take basename of files/dirs
Getty Ritter
10 years ago
| 24 | 24 | import System.Directory ( doesDirectoryExist |
| 25 | 25 | , getDirectoryContents |
| 26 | 26 | ) |
| 27 |
import System.FilePath ((</>) |
|
| 27 | import System.FilePath ((</>), takeBaseName) | |
| 28 | 28 | |
| 29 | 29 | filterDir :: IO [String] -> IO [String] |
| 30 | 30 | filterDir = fmap (filter go) |
| 165 | 165 | vs <- fmap sequence (mapM (parsePath withFile) [path </> k | k <- ks]) |
| 166 | 166 | case vs of |
| 167 | 167 | Left s -> return (Left s) |
| 168 | Right vs' -> return (Right (Object (fromList [ (pack k, v) | |
| 169 | | k <- ks | |
| 170 | | v <- vs' | |
| 171 | ]))) | |
| 168 | Right vs' -> | |
| 169 | return (Right (Object (fromList [ (pack (takeBaseName k), v) | |
| 170 | | k <- ks | |
| 171 | | v <- vs' | |
| 172 | ]))) | |