| 1 | (************************************************************************) |
| 2 | (* * The Rocq Prover / The Rocq Development Team *) |
| 3 | (* v * Copyright INRIA, CNRS and contributors *) |
| 4 | (* <O___,, * (see version control and CREDITS file for authors & dates) *) |
| 5 | (* \VV/ **************************************************************) |
| 6 | (* // * This file is distributed under the terms of the *) |
| 7 | (* * GNU Lesser General Public License Version 2.1 *) |
| 8 | (* * (see LICENSE file for the text of the license) *) |
| 9 | (************************************************************************) |
| 10 | |
| 11 | (** {5 System utilities} *) |
| 12 | |
| 13 | type physical_path = string |
| 14 | type load_path = physical_path list |
| 15 | |
| 16 | val physical_path_of_string : string -> physical_path |
| 17 | val string_of_physical_path : physical_path -> string |
| 18 | |
| 19 | (** Escape what has to be escaped (e.g. surround with quotes if with spaces) *) |
| 20 | val escaped_string_of_physical_path : physical_path -> string |
| 21 | |
| 22 | val canonical_path_name : string -> string |
| 23 | |
| 24 | (** Remove all initial "./" in a path *) |
| 25 | val remove_path_dot : string -> string |
| 26 | |
| 27 | (** If a path [p] starts with the current directory $PWD then |
| 28 | [strip_path p] returns the sub-path relative to $PWD. |
| 29 | Any leading "./" are also removed from the result. *) |
| 30 | val strip_path : string -> string |
| 31 | |
| 32 | (** correct_path f dir = dir/f if f is relative *) |
| 33 | val correct_path : string -> string -> string |
| 34 | |
| 35 | val path_to_list : string -> string list |
| 36 | |
| 37 | (** [make_suffix file suf] catenate [file] with [suf] when |
| 38 | [file] does not already end with [suf]. *) |
| 39 | val make_suffix : string -> string -> string |
| 40 | |
| 41 | val file_readable_p : string -> bool |
| 42 | |
| 43 | (** {6 Executing commands } *) |
| 44 | |
| 45 | (** [run_command com] launches command [com], and returns |
| 46 | the contents of stdout and stderr. If given, [~hook] |
| 47 | is called on each elements read on stdout or stderr. *) |
| 48 | |
| 49 | val run_command : |
| 50 | ?hook:(bytes->unit) -> string -> Unix.process_status * string |
| 51 | |
| 52 | (** [sys_command] launches program [prog] with arguments [args]. |
| 53 | It behaves like [Sys.command], except that we rely on |
| 54 | [Unix.create_process], it's hardly more complex and avoids dealing |
| 55 | with shells. In particular, no need to quote arguments |
| 56 | (against whitespace or other funny chars in paths), hence no need |
| 57 | to care about the different quoting conventions of /bin/sh and cmd.exe. *) |
| 58 | |
| 59 | val sys_command : string -> string list -> Unix.process_status |
| 60 | |
| 61 | (** A version of [Unix.waitpid] immune to EINTR exceptions *) |
| 62 | |
| 63 | val waitpid_non_intr : int -> Unix.process_status |
| 64 | |
| 65 | (** Check if two file names refer to the same (existing) file *) |
| 66 | val same_file : string -> string -> bool |
| 67 | |
| 68 | (** Like [Stdlib.Filename.temp_file] but producing a directory. *) |
| 69 | val mktemp_dir : ?temp_dir:string -> string -> string -> string |