Created
January 7, 2018 11:50
-
-
Save Heimdell/8eba4fc685a5f3992985ed07dcd7e364 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
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