The PathUtil structure provides support for searching for files
in the file system using a list of possible locations. It is implemented
using the SML Basis Library portable
file-system mechanisms and, thus, it itself portable across different
operating systems.
Synopsis
signature PATH_UTIL
structure PathUtil : PATH_UTIL
Interface
val findFile : string list -> string -> string option
val findFiles : string list -> string -> string list
val existsFile : (string -> bool) -> string list -> string -> string option
val allFiles : (string -> bool) -> string list -> string -> string list
val findExe : string list -> string -> string option
Description
val findFile : string list -> string -> string option-
findFile paths namereturnsSOME path, wherepathis a string of the form"p/name"andpis the first string inpathssuch thatpathexists. If no such file exists, thenNONEis returned. Ifnameis an absolute path, thenSOME nameis returned if it exists. val findFiles : string list -> string -> string list-
findFiles (paths, mode) namereturns a list of strings, such that each stringsin the result has the form"p/name"withpinpathsand the file named bypathexisting in the file system. val existsFile : (string -> bool) -> string list -> string -> string option-
existsFile pred paths namereturnsSOME path, wherepathis a string of the form"p/name"andpis the first string inpathssuch thatpathexists and thatpred pathreturns true. If no such file exists, thenNONEis returned. Ifnameis an absolute path, thenSOME nameis returned if it exists and satisfies the predicate. val allFiles : (string -> bool) -> string list -> string -> string list-
allFiles pred paths namereturns a list of strings, such that each stringsin the result has the form"p/name"withpinpaths, the file named bypathexisting in the file system, andpred pathreturnstrue. The order of the path list is preserved in the result. Ifnameis an absolute path, then the list[name]is returned ifnameexists and satisfies the predicate. val findExe : string list -> string -> string option-
findExe paths namesearchespathsfor an executable file with the given name. This expression is equivalent toexistsFile (fn p => OS.FileSys.access(p, [OS.FileSys.A_EXEC])) paths name