2 * Copyright (C) 2010-2011 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 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.
25 let set_up_progress_bar (g : Guestfs.guestfs) =
26 let progress_callback g event evh buf array =
27 if event = G.EVENT_PROGRESS && Array.length array >= 4 then (
28 (*let proc_nr = array.(0)
29 and serial = array.(1)*)
30 let position = array.(2)
31 and total = array.(3) in
34 if total <> 0L then Int64.to_float position /. Int64.to_float total
37 if ratio < 0. then 0. else if ratio > 1. then 1. else ratio in
39 let dots = int_of_float (ratio *. 72.) in
42 for i = 0 to dots-1 do print_char '#' done;
43 for i = dots to 71 do print_char '-' done;
45 if ratio = 1. then print_string "\n";
49 ignore (g#set_event_callback progress_callback [G.EVENT_PROGRESS])