2 * Copyright (C) 2009-2010 Red Hat Inc.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 val file_exists : string -> bool
22 (** Return [true] iff file exists. *)
24 val dir_exists : string -> bool
25 (** Return [true] iff dir exists. *)
27 val uniq : ?cmp:('a -> 'a -> int) -> 'a list -> 'a list
28 (** Uniquify a list (the list must be sorted first). *)
30 val sort_uniq : ?cmp:('a -> 'a -> int) -> 'a list -> 'a list
31 (** Sort and uniquify a list. *)
33 val input_all_lines : in_channel -> string list
34 (** Input all lines from a channel, returning a list of lines. *)
36 val run_command_get_lines : string -> string list
37 (** Run the command and read the list of lines that it prints to stdout. *)
39 val run_command : string -> unit
40 (** Run a command using {!Sys.command} and exit if it fails. Be careful
41 when constructing the command to properly quote any arguments
42 (using {!Filename.quote}). *)
44 val run_python : string -> string list -> unit
45 (** [run_python code args] runs Python [code] with arguments [args].
46 This does not return anything, but exits with an error message
47 if the Python code returns an error. *)
49 val tmpdir : unit -> string
50 (** [tmpdir ()] returns a newly created temporary directory. The
51 tmp directory is automatically removed when the program exits.
52 Note that a fresh temporary directory is returned each time you
53 call this function. *)
55 val (//) : string -> string -> string
56 (** [x // y] concatenates file paths [x] and [y] into a single path. *)
58 val find : string -> string -> int
59 (** [find str sub] searches for [sub] in [str], returning the index
60 or -1 if not found. *)
62 val string_split : string -> string -> string list
63 (** [string_split sep str] splits [str] at [sep]. *)
65 val string_prefix : string -> string -> bool
66 (** [string_prefix prefix str] returns true iff [str] starts with [prefix]. *)
68 val path_prefix : string -> string -> bool
69 (** [path_prefix prefix path] returns true iff [path] is [prefix] or
70 [path] starts with [prefix/]. *)
72 val filter_map : ('a -> 'b option) -> 'a list -> 'b list