The SML of NJ Library
The `UnixPath` structure

The `UnixPath` structure provides support for searching for files in the Unix file system using a list of possible locations.

Note that this module is largely superseded by the `PathUtil` module in the Util Library.

## Synopsis

    signature UNIX_PATH
    structure UnixPath : UNIX_PATH

## Interface

    type path_list = string list

    val getPath : unit -> path_list

    datatype access_mode = datatype OS.FileSys.access_mode
    datatype file_type = F_REGULAR | F_DIR | F_SYMLINK | F_SOCK | F_CHR | F_BLK

    val findFile : (path_list * access_mode list) -> string -> string option

    val findFiles : (path_list * access_mode list) -> string -> string list

    val findFileOfType : (path_list * file_type * access_mode list) -> string -> string option

    val findFilesOfType : (path_list * file_type * access_mode list) -> string -> string list

## Description

`type path_list = string list`

  A list of file-system paths that is used to search for files.

`val getPath : unit -> path_list`

  `getPath ()` return’s the value of the user’s `PATH` shell variable as a `path_list`.

`datatype access_mode = datatype OS.FileSys.access_mode`

  Rebind the file-system access-mode constructors.

`datatype file_type = F_REGULAR | F_DIR | F_SYMLINK | F_SOCK | F_CHR | F_BLK`

  The different types of file-system objects in Unix.

`val findFile : (path_list * access_mode list) -> string -> string option`

  `findFile (paths, mode) name` returns `SOME path`, where `path` is a string of the form `"p/name"` and `p` is the first string in `paths` such that `path` has the given access modes (the empty list of access modes is used to test for existence). If no such file exists, then `NONE` is returned.

`val findFiles : (path_list * access_mode list) -> string -> string list`

  `findFiles (paths, mode) name` returns a list of strings, such that each string `s` in the result has the form `"p/name"` with `p` in `paths` and the file named by `path` has the specified access modes.

`val findFileOfType : (path_list * file_type * access_mode list) -> string -> string option`

  `findFileOfType (paths, ftype, mode) name` returns the `SOME path`, where `path` is a string of the form `"p/name"` and `p` is the first string in `paths` such that `path` has the given access modes (the empty list of access modes is used to test for existence) and is of the specified file type. If no such file exists, then `NONE` is returned.

`val findFilesOfType : (path_list * file_type * access_mode list) -> string -> string list`

  `findFilesOfType (paths, mode) name` returns a list of strings, such that each string `s` in the result has the form `"p/name"` with `p` in `paths` and the file named by `path` has the specified access modes and is of the specified file type.

## See Also

`UnixEnv`, `PathUtil`, The Unix Library

SML/NJ Version 110.99.3 (August 1, 2023)
Last updated 2023-07-31 17:59:01 UTC