]> matita.cs.unibo.it Git - helm.git/blob - helm/ocaml/getter/http_getter_misc.mli
ocaml 3.09 transition
[helm.git] / helm / ocaml / getter / http_getter_misc.mli
1 (*
2  * Copyright (C) 2003-2004:
3  *    Stefano Zacchiroli <zack@cs.unibo.it>
4  *    for the HELM Team http://helm.cs.unibo.it/
5  *
6  *  This file is part of HELM, an Hypertextual, Electronic
7  *  Library of Mathematics, developed at the Computer Science
8  *  Department, University of Bologna, Italy.
9  *
10  *  HELM is free software; you can redistribute it and/or
11  *  modify it under the terms of the GNU General Public License
12  *  as published by the Free Software Foundation; either version 2
13  *  of the License, or (at your option) any later version.
14  *
15  *  HELM is distributed in the hope that it will be useful,
16  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  *  GNU General Public License for more details.
19  *
20  *  You should have received a copy of the GNU General Public License
21  *  along with HELM; if not, write to the Free Software
22  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston,
23  *  MA  02111-1307, USA.
24  *
25  *  For details, see the HELM World-Wide-Web page,
26  *  http://helm.cs.unibo.it/
27  *)
28
29  (** 'mkdir' failed, arguments are: name of the directory to be created and
30  failure reason *)
31 exception Mkdir_failure of string * string
32
33   (** @return Some localpart for URI belonging to the "file://" scheme, None for
34   * other URIs
35   * removes trailing ".gz", if any
36   * e.g.: local_url "file:///etc/passwd.gz" = Some "/etc/passwd"
37   *       local_url "http://...." = None *)
38 val local_url: string -> string option
39
40  (** "fold_left" like function on file lines, trailing newline is not passed to
41  the given function *)
42 val fold_file : (string -> 'a -> 'a) -> 'a -> string -> 'a
43
44  (* "iter" like function on file lines, trailing newline is not passed to the
45  given function *)
46 val iter_file : (string -> unit) -> string -> unit
47
48  (* "iter" like function on file data chunks of fixed size *)
49 val iter_file_data: (string -> unit) -> string -> unit
50
51   (** like Hashtbl.fold but keys are processed ordered *)
52 val hashtbl_sorted_fold :
53   ('a -> 'b -> 'c -> 'c) -> ('a, 'b) Hashtbl.t -> 'c -> 'c
54   (** like Hashtbl.iter but keys are processed ordered *)
55 val hashtbl_sorted_iter : ('a -> 'b -> unit) -> ('a, 'b) Hashtbl.t -> unit
56
57 val list_uniq: 'a list -> 'a list (* uniq unix filter on lists *)
58
59   (** cp frontend *)
60 val cp: string -> string -> unit
61   (** wget frontend, if output is given it is the destination file, otherwise
62   standard wget rules are used. Additionally this function support also the
63   "file://" scheme for file system addressing *)
64 val wget: ?output: string -> string -> unit
65   (** gzip frontend. If keep = true original file will be kept, default is
66   false. output is the file on which gzipped data will be saved, default is
67   given file with an added ".gz" suffix *)
68 val gzip: ?keep: bool -> ?output: string -> string -> unit
69   (** gunzip frontend. If keep = true original file will be kept, default is
70   false. output is the file on which gunzipped data will be saved, default is
71   given file name without trailing ".gz" *)
72 val gunzip: ?keep: bool -> ?output: string -> string -> unit
73   (** tempfile frontend, return the name of created file. A special purpose
74   suffix is used (actually "_http_getter" *)
75 val tempfile: unit -> string
76   (** mkdir frontend, if parents = true also parent directories will be created.
77   If the given directory already exists doesn't act.
78   parents defaults to false *)
79 val mkdir: ?parents:bool -> string -> unit
80
81   (** pretty printer for Unix.process_status values *)
82 val string_of_proc_status : Unix.process_status -> string
83
84   (** raw URL downloader, return Some the contents of downloaded resource or
85   None if an error occured while downloading. This function support also
86   "file://" scheme for filesystem resources *)
87 val http_get: string -> string option
88
89   (** true on blanks-only and #-commented lines, false otherwise *)
90 val is_blank_line: string -> bool
91
92 val normalize_dir: string -> string (** add trailing "/" if missing *)
93 val strip_trailing_slash: string -> string
94 val strip_suffix: suffix:string -> string -> string
95
96 val extension: string -> string  (** @return string part after rightmost "." *)
97
98 val temp_file_of_uri: string -> string * out_channel
99
100   (** execute a command and return first line of what it prints on stdout *)
101 val backtick: string -> string
102