Actually remove directories (#9849)

`rm_rf` removed the files (recursively) but not the directories.
master
David Allsopp 2020-08-20 15:06:46 +01:00 committed by GitHub
parent 53fe14a541
commit 781b37b688
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 7 deletions

View File

@ -315,9 +315,9 @@ Working version
attributes are present.
(Matthew Ryan, review by Nicolás Ojeda Bär)
- #9797: Eliminate the routine use of external commands in ocamltest. ocamltest
no longer calls the mkdir, rm and ln external commands (at present, the only
external command ocamltest uses is diff).
- #9797, #9849: Eliminate the routine use of external commands in ocamltest.
ocamltest no longer calls the mkdir, rm and ln external commands (at present,
the only external command ocamltest uses is diff).
(David Allsopp, review by Nicolás Ojeda Bär, Sébastien Hinderer and
Xavier Leroy)

View File

@ -94,10 +94,11 @@ module Sys = struct
let rm_rf path =
let rec erase path =
if Sys.is_directory path
then Array.iter (fun entry -> erase (Filename.concat path entry))
(Sys.readdir path)
else erase_file path
if Sys.is_directory path then begin
Array.iter (fun entry -> erase (Filename.concat path entry))
(Sys.readdir path);
Sys.rmdir path
end else erase_file path
in
try if Sys.file_exists path then erase path
with Sys_error err ->