Commit 3d12b47d authored by Andrei Paskevich's avatar Andrei Paskevich

remove a old backup before creating a new one

parent 910227ca
......@@ -28,7 +28,7 @@ open Rc
- 5 cvc3 native
- 6 driver renaming
- 7 yices native (used for release 0.70)
- 8 for release 0.71
- 8 for release 0.71
If a configuration doesn't contain the actual magic number we don't use it.*)
......@@ -247,7 +247,7 @@ let read_config conf_file =
let save_config config =
let filename = config.conf_file in
if Sys.file_exists filename then Sys.rename filename (filename ^ ".bak");
Sysutil.backup_file filename;
to_file filename config.config
let get_main config = config.main
......
......@@ -610,6 +610,8 @@ let schedule_edit_proof ~debug:_ ~editor ~file ~driver ~callback goal =
then
begin
let backup = file ^ ".bak" in
if Sys.file_exists backup
then Sys.remove backup;
Sys.rename file backup;
Some(open_in backup)
end
......@@ -1537,11 +1539,7 @@ let save_session () =
match !current_env with
| Some _ ->
let f = Filename.concat !project_dir db_filename in
begin if Sys.file_exists f then
let b = f ^ ".bak" in
if Sys.file_exists b then Sys.remove b ;
Sys.rename f b
end;
Sysutil.backup_file f;
save f
| None ->
eprintf "Session.save_session: no session opened@.";
......
......@@ -17,6 +17,13 @@
(* *)
(**************************************************************************)
let backup_file f =
if Sys.file_exists f then begin
let fb = f ^ ".bak" in
if Sys.file_exists fb then Sys.remove fb;
Sys.rename f fb
end
let channel_contents_fmt cin fmt =
let buff = String.make 1024 ' ' in
let n = ref 0 in
......
......@@ -17,6 +17,9 @@
(* *)
(**************************************************************************)
(* create a backup copy of a file if it exists *)
val backup_file : string -> unit
(* return the content of an in-channel *)
val channel_contents : in_channel -> string
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment