virt tools: Use Sys.file_exists instead of clumsy open_in/close_in hack.

No functional change.

Fixes commit c466d4cb92.
This commit is contained in:
Richard W.M. Jones
2016-06-23 14:44:14 +01:00
parent 8f8a651e59
commit 7c52d86de9
2 changed files with 2 additions and 15 deletions

View File

@@ -193,13 +193,7 @@ module Windows = struct
let srvany =
try
List.find (
fun service ->
try
let chan = open_in (virt_tools_data_dir // service) in
close_in chan;
true
with _ ->
false
fun service -> Sys.file_exists (virt_tools_data_dir // service)
) services
with Not_found ->
error (f_"One of rhsrvany.exe or pvvxsvc.exe is missing in %s. One of them is required in order to install Windows firstboot scripts. You can get one by building rhsrvany (https://github.com/rwmjones/rhsrvany)")

View File

@@ -48,14 +48,7 @@ let convert ~keep_serial_console (g : G.guestfs) inspect source rcaps =
let installer =
try
let t, tool = List.find (
fun (_, tool) ->
try (
let exe_path = virt_tools_data_dir // tool in
let chan = open_in exe_path in
close_in chan;
true
) with _ ->
false
fun (_, tool) -> Sys.file_exists (virt_tools_data_dir // tool)
) tools in
Some (t, virt_tools_data_dir // tool)
with Not_found -> (