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 name
returnsSOME path
, wherepath
is a string of the form"p/name"
andp
is the first string inpaths
such thatpath
exists. If no such file exists, thenNONE
is returned. Ifname
is an absolute path, thenSOME name
is returned if it exists. val findFiles : string list -> string -> string list
-
findFiles (paths, mode) name
returns a list of strings, such that each strings
in the result has the form"p/name"
withp
inpaths
and the file named bypath
existing in the file system. val existsFile : (string -> bool) -> string list -> string -> string option
-
existsFile pred paths name
returnsSOME path
, wherepath
is a string of the form"p/name"
andp
is the first string inpaths
such thatpath
exists and thatpred path
returns true. If no such file exists, thenNONE
is returned. Ifname
is an absolute path, thenSOME name
is returned if it exists and satisfies the predicate. val allFiles : (string -> bool) -> string list -> string -> string list
-
allFiles pred paths name
returns a list of strings, such that each strings
in the result has the form"p/name"
withp
inpaths
, the file named bypath
existing in the file system, andpred path
returnstrue
. The order of the path list is preserved in the result. Ifname
is an absolute path, then the list[name]
is returned ifname
exists and satisfies the predicate. val findExe : string list -> string -> string option
-
findExe paths name
searchespaths
for an executable file with the given name. This expression is equivalent toexistsFile (fn p => OS.FileSys.access(p, [OS.FileSys.A_EXEC])) paths name