Effacer le .cmi si exception pendant son ecriture

git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@2963 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
master
Xavier Leroy 2000-03-16 15:09:39 +00:00
parent b070d1dce0
commit c96be2df9c
1 changed files with 17 additions and 12 deletions

View File

@ -788,18 +788,23 @@ let save_signature sg modname filename =
components_of_module empty Subst.identity
(Pident(Ident.create_persistent modname)) (Tmty_signature sg) in
let oc = open_out_bin filename in
output_string oc cmi_magic_number;
output_value oc (modname, sg);
flush oc;
let crc = Digest.file filename in
let crcs = (modname, crc) :: imported_units() in
output_value oc crcs;
close_out oc;
(* Enter signature in persistent table so that imported_unit()
will also return its crc *)
let ps =
{ ps_name = modname; ps_sig = sg; ps_comps = comps; ps_crcs = crcs } in
Hashtbl.add persistent_structures modname ps
try
output_string oc cmi_magic_number;
output_value oc (modname, sg);
flush oc;
let crc = Digest.file filename in
let crcs = (modname, crc) :: imported_units() in
output_value oc crcs;
(* Enter signature in persistent table so that imported_unit()
will also return its crc *)
let ps =
{ ps_name = modname; ps_sig = sg; ps_comps = comps; ps_crcs = crcs } in
Hashtbl.add persistent_structures modname ps;
close_out oc
with exn ->
close_out oc;
remove_file filename;
raise exn
(* Make the initial environment *)