Created
November 6, 2011 10:49
-
-
Save tsurushuu/1342745 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Main where | |
import System.Directory | |
import Control.Monad | |
import Data.List | |
import Text.Regex | |
import Text.Regex.Posix | |
recursiveFiles :: FilePath -> IO [FilePath] | |
recursiveFiles path = getDirectoryContents path | |
getDirectoryContentsRecursive :: FilePath -> IO [FilePath] | |
getDirectoryContentsRecursive path = do | |
isDir <- doesDirectoryExist path | |
if isDir | |
then do | |
cs <- getDirectoryContents path | |
liftM concat $ mapM getDirectoryContentsRecursive $ map ((path ++ "/") ++) $ filter (`notElem` [".", ".."]) cs | |
else return [path] | |
main = do | |
cs <- getDirectoryContentsRecursive "." | |
putStrLn $ unlines $ filter ((=~ "(\\.cpp$)") :: FilePath -> Bool) cs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment