2 * Copyright (C) 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.
23 let rec download_as_reg (tree : Filetree.tree) (path, hivexregedit) =
24 let model = tree#model in
25 let row = model#get_iter path in
27 (* Get path to the top of the registry tree. *)
28 let registry, nodes = tree#get_registry_path row in
29 let regpath = String.concat "\\" (List.rev nodes) in
30 let rootkey = Filetree.root_key_of_registry_t registry in
31 debug "download_as_reg: %s %s" rootkey regpath;
33 (* Force the registry to be downloaded, if not already. *)
34 tree#get_registry_file path registry
35 (when_downloaded tree path hivexregedit rootkey nodes regpath)
37 and when_downloaded tree path hivexregedit rootkey nodes regpath cachefile =
38 (* Put up the dialog. *)
39 let title = "Download as .reg file" in
40 let dlg = GWindow.file_chooser_dialog ~action:`SAVE ~title ~modal:true () in
41 dlg#add_button_stock `CANCEL `CANCEL;
42 dlg#add_select_button_stock `SAVE `SAVE;
43 let name = match nodes with [] -> rootkey | (name::_) -> name in
44 dlg#set_current_name (name ^ ".reg");
47 | `DELETE_EVENT | `CANCEL ->
50 match dlg#filename with
55 (* Use hivexregedit to save it. *)
57 sprintf "%s --export --prefix %s %s %s > %s"
58 (Filename.quote hivexregedit)
59 (Filename.quote rootkey) (Filename.quote cachefile)
60 (Filename.quote regpath) (Filename.quote localfile) in
61 Slave.run_command cmd Slave.no_callback