Skip to content

Instantly share code, notes, and snippets.

@tsurushuu
Created November 6, 2011 10:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tsurushuu/1342745 to your computer and use it in GitHub Desktop.
Save tsurushuu/1342745 to your computer and use it in GitHub Desktop.
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