configure: Detect camlp4 and bail if not available.
[guestfs-browser.git] / op_checksum_file.ml
1 (* Guestfs Browser.
2  * Copyright (C) 2011 Red Hat Inc.
3  *
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.
8  *
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.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17  *)
18
19 open Utils
20
21 open Printf
22
23 let rec checksum_file tree (path, csumtype) =
24   let model = tree#model in
25   let row = model#get_iter path in
26   let src, pathname = tree#get_pathname row in
27   debug "checksum_file %s" pathname;
28
29   (* See if this node already has an Info "checksum" child
30    * node.  If so they don't recreate it.
31    *)
32   let info_text = "checksum:" ^ csumtype in
33   if not (tree#has_child_info_node path info_text) then (
34     tree#set_child_info_node path info_text
35       (sprintf "<i>Calculating %s ...</i>" csumtype);
36
37     Slave.checksum_file src pathname csumtype
38       (when_checksum_file tree path pathname csumtype)
39   )
40
41 and when_checksum_file tree path pathname csumtype checksum =
42   let model = tree#model in
43   let row = model#get_iter path in
44   tree#set_visited row;
45
46   (* Find the child node added above, and replace the text. *)
47   let info_text = "checksum:" ^ csumtype in
48   let msg = sprintf "%s: %s" csumtype checksum in
49   tree#set_child_info_node path info_text msg