Thursday, 2 June 2016

Haskell: findExecutables: Get all the paths of executable file


System.Directory module provides findExecutables function which takes file name as argument and return a list of all occurrences that are executable. It returns an empty list, if it don’t find any executable. Following is the signature of findExecutables function.
Prelude System.Directory> :t findExecutables 
findExecutables :: String -> IO [FilePath]
Prelude System.Directory> findExecutables "java"
["/usr/bin/java","/bin/java"]
Prelude System.Directory> findExecutables "javac"
["/usr/bin/javac"]
Prelude System.Directory> findExecutables "cabal"
["/usr/local/bin/cabal"]
Prelude System.Directory> findExecutables "Krishna"
[]

Note
On Windows this function returns only the first occurrence of the executable.





Previous                                                 Next                                                 Home

No comments:

Post a Comment