(* 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 tmpdir = tmpdir () let rec view_file tree (path, opener) = let model = tree#model in let row = model#get_iter path in let src, pathname = tree#get_pathname row in debug "view_file %s" pathname; (* Download the file into a temporary directory. *) let ext = extension pathname in let localfile = tmpdir // string_of_int (unique ()) ^ ext in Slave.download_file src pathname localfile (when_downloaded_file_for_view tree path opener localfile) and when_downloaded_file_for_view tree path opener localfile () = let model = tree#model in let row = model#get_iter path in tree#set_visited row; let cmd = sprintf "%s %s" (Filename.quote opener) (Filename.quote localfile) in Slave.run_command cmd Slave.no_callback