Thursday 2 June 2016

Haskell: findFile: Search for a file in given directories

System.Directory module provides findFile function which takes list of directories and a file as an argument and return ‘Just path’ if the file is available, else Nothing. Following is the signature of findFile function.

Prelude System.Directory> :t findFile

findFile :: [FilePath] -> String -> IO (Maybe FilePath)
Prelude System.Directory> findFile ["/", "/Users/harikrishna_gurram", "/var"] "academyLogin.log"
Just "/Users/harikrishna_gurram/academyLogin.log"
Prelude System.Directory> 
Prelude System.Directory> findFile ["/", "/Users/harikrishna_gurram", "/var"] "academyLogin.log.123"
Nothing


Previous                                                 Next                                                 Home

No comments:

Post a Comment