(* Guestfs Browser. * Copyright (C) 2011 Red Hat Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *) open Utils open Printf let rec download_as_reg (tree : Filetree.tree) (path, hivexregedit) = let model = tree#model in let row = model#get_iter path in (* Get path to the top of the registry tree. *) let registry, nodes = tree#get_registry_path row in let regpath = String.concat "\\" (List.rev nodes) in let rootkey = Filetree.root_key_of_registry_t registry in debug "download_as_reg: %s %s" rootkey regpath; (* Force the registry to be downloaded, if not already. *) tree#get_registry_file path registry (when_downloaded tree path hivexregedit rootkey nodes regpath) and when_downloaded tree path hivexregedit rootkey nodes regpath cachefile = (* Put up the dialog. *) let title = "Download as .reg file" in let dlg = GWindow.file_chooser_dialog ~action:`SAVE ~title ~modal:true () in dlg#add_button_stock `CANCEL `CANCEL; dlg#add_select_button_stock `SAVE `SAVE; let name = match nodes with [] -> rootkey | (name::_) -> name in dlg#set_current_name (name ^ ".reg"); match dlg#run () with | `DELETE_EVENT | `CANCEL -> dlg#destroy () | `SAVE -> match dlg#filename with | None -> () | Some localfile -> dlg#destroy (); (* Use hivexregedit to save it. *) let cmd = sprintf "%s --export --prefix %s %s %s > %s" (Filename.quote hivexregedit) (Filename.quote rootkey) (Filename.quote cachefile) (Filename.quote regpath) (Filename.quote localfile) in Slave.run_command cmd Slave.no_callback