From 8872bb399802e967aaf8e4389f4f0c1ec7d65dcf Mon Sep 17 00:00:00 2001 From: Nicolas Berthier Date: Fri, 2 Mar 2018 14:27:15 +0000 Subject: [PATCH] Do not remove sub-directories in `Compiler_utils.clean_dir' --- compiler/utilities/global/compiler_utils.ml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/compiler/utilities/global/compiler_utils.ml b/compiler/utilities/global/compiler_utils.ml index 7d3329e..9a763cb 100644 --- a/compiler/utilities/global/compiler_utils.ml +++ b/compiler/utilities/global/compiler_utils.ml @@ -107,7 +107,10 @@ let build_path suf = let clean_dir dir = if Sys.file_exists dir && Sys.is_directory dir then begin - let rm_file_in_dir fn = Sys.remove (Filename.concat dir fn) in + let rm_file_in_dir fn = + let f = Filename.concat dir fn in + if not (Sys.is_directory f) then Sys.remove f + in Array.iter rm_file_in_dir (Sys.readdir dir); end else Unix.mkdir dir 0o740; dir