(*********************************************************************************) |
(* Cameleon *)
(* *)
(* Copyright (C) 2005,2006 Institut National de Recherche en Informatique *)
(* et en Automatique. All rights reserved. *)
(* *)
(* This program is free software; you can redistribute it and/or modify *)
(* it under the terms of the GNU Library General Public License as *)
(* published by the Free Software Foundation; either version 2 of the *)
(* License, or 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 Library General Public License for more details. *)
(* *)
(* You should have received a copy of the GNU Library General Public *)
(* License along with this program; if not, write to the Free Software *)
(* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA *)
(* 02111-1307 USA *)
(* *)
(* Contact: Maxence.Guesdon@inria.fr *)
(* *)
(*********************************************************************************) |
(*c==v=[Misc.safe_main]=1.0====*)
let safe_main main =
try main ()
with
Failure s
| Sys_error s ->
prerr_endline s;
exit 1
(*/c==v=[Misc.safe_main]=1.0====*)
(*c==v=[File.value_of_file]=1.0====*)
let value_of_file name =
let ic = open_in_bin name in
try
let v = input_value ic in
close_in ic;
v
with
| e -> close_in ic; raise e
(*/c==v=[File.value_of_file]=1.0====*)
(*c==v=[File.file_of_value]=1.0====*)
let file_of_value name s =
let oc = open_out_bin name in
output_value oc s;
close_out oc
(*/c==v=[File.file_of_value]=1.0====*)
(*c==v=[String.chop_n_char]=1.0====*)
let chop_n_char n s =
let len = String.length s in
if len <= n +1 or n < 0 then
s
else
Printf.sprintf "%s..." (String.sub s 0 (n+1))
(*/c==v=[String.chop_n_char]=1.0====*)