Skip to content

Instantly share code, notes, and snippets.

@Heimdell
Created January 7, 2018 11:50
Show Gist options
  • Save Heimdell/8eba4fc685a5f3992985ed07dcd7e364 to your computer and use it in GitHub Desktop.
Save Heimdell/8eba4fc685a5f3992985ed07dcd7e364 to your computer and use it in GitHub Desktop.
import Control.Exception ( SomeException(..), catch )
import Control.Monad ( when )
import Data.Foldable ( for_ )
import System.Directory ( doesDirectoryExist
, doesPathExist
, listDirectory
, pathIsSymbolicLink
)
import System.FilePath ( (</>) )
main = filenames "/"
filenames rootPath = do
yes <- doesPathExist rootPath
link <- pathIsSymbolicLink rootPath
when (yes && not link) $ do
dir <- doesDirectoryExist rootPath
if dir
then do
list <- listDirectory rootPath
for_ list $ \file -> do
filenames (rootPath </> file)
else do
putStrLn rootPath
`catch` \(SomeException e) ->
return ()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment