/usr/lib/ocaml/ocamlbricks/unixExtra.mli is in libocamlbricks-ocaml-dev 0.90+bzr400-1build2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 | (* This file is part of our reusable OCaml BRICKS library
Copyright (C) 2009 Jean-Vincent Loddo
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. *)
(** Additional features for the standard library [Unix]. *)
type filename = string
type foldername = string
type content = string
val apply_ignoring_Unix_error : ('a -> unit) -> 'a -> unit
val apply_catching_Unix_error : fallback:(Unix.error * string * string -> 'b) -> ('a -> 'b) -> 'a -> 'b
(** {2 File permissions} *)
type symbolic_mode = (bool*bool*bool)*(bool*bool*bool)*(bool*bool*bool)
val update_symbolic_mode :
?u:unit -> ?g:unit -> ?o:unit -> ?a:unit -> ?r:bool -> ?w:bool -> ?x:bool ->
symbolic_mode -> symbolic_mode
val get_umask : unit -> symbolic_mode
val set_umask : (bool*bool*bool) -> (bool*bool*bool) -> (bool*bool*bool) -> unit
val update_umask :
?u:unit -> ?g:unit -> ?o:unit -> ?a:unit -> ?r:bool -> ?w:bool -> ?x:bool ->
unit -> unit
val test_access : ?r:unit -> ?w:unit -> ?x:unit -> filename -> bool
val touch : ?perm:Unix.file_perm -> filename -> unit
val get_perm : filename -> symbolic_mode
val set_perm :
?u:unit -> ?g:unit -> ?o:unit -> ?a:unit -> ?r:bool -> ?w:bool -> ?x:bool ->
filename -> unit
(** {2 Copying files} *)
val file_copy : ?buffer_size:int -> ?perm:Unix.file_perm -> filename -> filename -> unit
val file_append : ?buffer_size:int -> ?perm:Unix.file_perm -> filename -> filename -> unit
val file_move : filename -> filename -> unit
(** {2 Saving strings} *)
val put : ?perm:Unix.file_perm -> filename -> content -> unit
val rewrite : ?perm:Unix.file_perm -> filename -> content -> unit
val append : ?perm:Unix.file_perm -> filename -> content -> unit
(** {2 Loading strings} *)
val cat : filename -> string
(** {2 Temporary files} *)
val temp_dir :
?perm:Unix.file_perm ->
?parent:string -> ?prefix:string -> ?suffix:string -> unit -> string
val temp_file :
?perm:Unix.file_perm ->
?parent:string ->
?prefix:string -> ?suffix:string -> ?content:content -> unit -> string
module TMPDIR :
sig
val default_prefix : string
val open_temp :
?perm:Unix.file_perm ->
?prefix:string -> ?suffix:string -> unit -> string * Unix.file_descr
val temp_file :
?perm:Unix.file_perm ->
?prefix:string -> ?suffix:string -> unit -> string
end
(** {2 File kind} *)
val file_kind_of_char : char -> Unix.file_kind option
(** {2 Directories} *)
val iter_dir : (string -> 'a) -> string -> unit
val find :
?follow:unit ->
?maxdepth:int ->
?kind:char ->
?basename:string ->
?only_first:unit ->
string list -> string list * exn list
val find_fold :
?follow:unit ->
?maxdepth:int ->
?kind:char ->
?basename:string ->
?only_first:unit ->
('a -> string * string list * exn list -> 'a) -> 'a -> string list -> 'a
val find_first_and_map :
?follow:unit ->
?maxdepth:int ->
?kind:char ->
?basename:string ->
(string -> string -> 'a) ->
string list -> 'a option
(** {2 Password} *)
val read_passwd : string -> string
(** {2 Process status} *)
val string_of_process_status : Unix.process_status -> string
(** {2 Managing external programs} *)
type command = string
type program = string
val path_of_implicit : program -> string option
(** Version working in the both cases implicit/explicit program
reference as a shell interpreter. *)
val is_executable : program -> bool
(** Version working in the both cases implicit/explicit program
reference as a shell interpreter. *)
val resolve_executable : ?realpath:unit -> program -> string option
val system_or_fail : ?hide_output:bool -> ?hide_errors:bool -> command -> unit
val kill_safe : int -> int -> unit
exception Signal_forward of int
exception Waitpid
val create_process_and_wait :
?stdin:Endpoint.Source.t ->
?stdout:Endpoint.Sink.t ->
?stderr:Endpoint.Sink.t ->
?pseudo:string ->
?forward:int list ->
?register_pid:(int->unit) ->
program -> string list -> int
type process_result = int * string * string
val create_process_and_wait_then_get_result :
?stdin:Endpoint.Source.t ->
?stdout:Endpoint.Sink.t ->
?stderr:Endpoint.Sink.t ->
?pseudo:string ->
?forward:int list ->
?register_pid:(int->unit) ->
program -> string list -> process_result
val run : ?shell:command -> ?trace:bool -> ?input:string -> command -> string * Unix.process_status
val shell : ?shell:command -> ?trace:bool -> ?input:string -> command -> string
(** {b Asynchronous version} *)
val future :
?stdin:Endpoint.Source.t ->
?stdout:Endpoint.Sink.t ->
?stderr:Endpoint.Sink.t ->
?pseudo:string ->
?forward:int list ->
?register_pid:(int->unit) ->
program -> string list -> process_result Future.t
val kfuture :
?stdin:Endpoint.Source.t ->
?stdout:Endpoint.Sink.t ->
?stderr:Endpoint.Sink.t ->
?pseudo:string ->
?forward:int list ->
?register_pid:(int->unit) ->
program -> string list -> (int -> string -> string ->'a) -> 'a Future.t
val script :
?stdin:Endpoint.Source.t ->
?stdout:Endpoint.Sink.t ->
?stderr:Endpoint.Sink.t ->
?pseudo:string ->
?forward:int list ->
?register_pid:(int->unit) ->
content -> string list -> process_result
val script_future :
?stdin:Endpoint.Source.t ->
?stdout:Endpoint.Sink.t ->
?stderr:Endpoint.Sink.t ->
?pseudo:string ->
?forward:int list ->
?register_pid:(int->unit) ->
content -> string list -> process_result Future.t
type pid = int
val is_process_alive : pid -> bool
module Process : sig
type status =
| WUNCHANGED
| WEXITED of int
| WSIGNALED of int
| WSTOPPED of int
| WCONTINUED
type wait_flag =
| WNOHANG
| WUNTRACED
| WCONTINUE
val waitpid : wait_flag list -> pid -> int * status
val string_of_status : status -> string
(** Similar to waitpid but protected from the exception [Unix.Unix_error (Unix.EINTR, _, _)].
If this exception is raised, the function recall itself in order to wait again: *)
val waitpid_non_intr : ?wait_flags:wait_flag list -> pid -> (exn, int * status) Either.t
(** Similar to [waitpid_non_intr] but protected also from the exception:
[Unix.Unix_error (Unix.ECHILD, _, _)] which may simply mean that the process doesn't exist
or it is already terminated (and wait-ed by someone else). In this case, the function returns immediately.
However, if this exception is raised when the process is still alive, this means that the process
cannot be wait-ed (is not a child or a descendant). In this case, an exception [Invalid_argument] is raised. *)
val join_process : pid -> unit
end (* Process *)
module Dir : sig
type t = string
val iter : ?entry_kind:Unix.file_kind -> ?follow:unit -> (string -> unit) -> t -> unit
val to_list : ?entry_kind:Unix.file_kind -> ?follow:unit -> t -> string list
val map : ?entry_kind:Unix.file_kind -> ?follow:unit -> (string -> 'a) -> t -> 'a list
val fold : ?entry_kind:Unix.file_kind -> ?follow:unit -> ('a -> string -> 'a) -> 'a -> t -> 'a
val iter_with_kind : ?follow:unit -> (string -> Unix.file_kind -> unit) -> t -> unit
val to_list_with_kind : ?follow:unit -> t -> (string * Unix.file_kind) list
val map_with_kind : ?follow:unit -> (string -> Unix.file_kind -> 'a) -> t -> 'a list
val fold_with_kind : ?follow:unit -> ('a -> string -> Unix.file_kind -> 'a) -> 'a -> t -> 'a
end (* Dir *)
val date : ?gmt:unit -> ?dash:string -> ?dot:string -> ?colon:string -> ?no_time:unit -> ?no_date:unit
-> unit -> string
val resolve_symlink : ?max_hops:int -> string -> string
val is_symlink : string -> bool
module Thread_unsafe : sig
val realpath : ?s:unit -> string -> string option
end
val realpath : ?s:unit -> string -> string option
|