Skip to content

Commit e88b0e2

Browse files
committed
Remove remove old result dir in direct g2html output
1 parent e84a0ce commit e88b0e2

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/framework/xsltResultOutput.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,7 @@ struct
309309

310310
let output table live gtable gtfxml (module FileCfg: MyCFG.FileCfg) =
311311
let result_dir = Fpath.(v "result") in
312+
GobSys.rmdir_recursive_if_exists result_dir;
312313
GobSys.mkdir_or_exists result_dir;
313314
let file = FileCfg.file in
314315
let file2funs = SH.create 100 in

src/util/std/gobSys.ml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ let rmdir_if_empty dirname =
2525
with Unix.Unix_error (Unix.ENOTEMPTY, _, _) ->
2626
()
2727

28-
(** Remove directory and its content, as "rm -rf" would do. *)
28+
(** Remove directory and its content, as "rm -rf" would do.
29+
@raise Sys_error if [path] doesn't exist. *)
2930
let rmdir_recursive path =
3031
let rec f path =
3132
let path_str = Fpath.to_string path in
@@ -38,6 +39,12 @@ let rmdir_recursive path =
3839
in
3940
f path
4041

42+
let rmdir_recursive_if_exists path =
43+
try
44+
rmdir_recursive path
45+
with Sys_error _ ->
46+
()
47+
4148

4249
let exe_dir = Fpath.(parent (v Sys.executable_name))
4350

0 commit comments

Comments
 (0)